Hi everyone, 

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 : 

http://uk.mathworks.com/help/matlab/ref/textscan.html

http://uk.mathworks.com/help/matlab/ref/fprintf.html

http://uk.mathworks.com/help/matlab/matlab_env/run-external-commands-scripts-and-programs.html?refresh=true

Hope this helps.

You need to be a member of SWMM 5 or SWMM or EPASWMM and SWMM5 in ICM_SWMM to add comments!

Join SWMM 5 or SWMM or EPASWMM and SWMM5 in ICM_SWMM

Email me when people reply –

Replies

  • Hello everybody!, I have encountered the same issue in the last year, and because of this I have developed an open source solution to replicate the SWMM algorithm in Matlab, Python, and LabVIEW easily. I have called it MatSWMM an it is available at: https://github.com/water-systems/MatSWMM

    MatSWMM can be useful to model Real-time control for urban drainage systems, extract simulation results and edit systematically a system that has been created with the SWMM platform. I hope this can be useful to fullfil the requirements of the unpleasant batch simulation problems. 

    Please check it out, and feel free to contact me (ga.riano949@uniandes.edu.co) if any doubt or suggestion appears. 

This reply was deleted.