I found there were many questions about how to call SWMM in matlab, and this problem has bothered me for a long time.
Now I find a way to combine MATLAB with SWMM, it solve my problem, and I want to share with your guys .
The principle is to read and change .inp file of SWMM, and call swmm in MATLAB, then read the .rpt file to import data to matlab workspace.
The step and the main command are like below:
1. use the command 'textscan' in matlab to read .inp file, the result will be a cell, then use 'strcmp' to find the exact section you care about, then use ' textscan' again to read the each line of the cell of the exact section which you want to change.
2. use 'fprintf' to rewrite the parameters into the .inp file. (Notice: format control, make sure the length of string is equal to the original )
3. ! swmm5.exe test.inp test.rpt ( this is a command to call external programs, you need change the name of the inp & rpt file into whatever you want )
4. the detial result is given in .rpt, so just use 'textscan ' to read them to matlab workspace, remember use ' strcmp' to find the exact line you concern about.
these are some links :
Hope this helps.