How can I incorporate a S-function in Simulink so that it executes a code written in MATLAB?

As a part of my dynamic system modelling of rainfall induced runoff processes, I would like to include a S-function block to write if else codes for getting the runoff as output after deducting the losses from initial rainfall. If R1, ET and V are the input signals where R1 & ET are time series data & V is a constant. I would like to use 'from workspace' block to import the input signals. The if-else code is given below: function R2 = sfunj_depressionLoss(R1,ET,V) if R1<= ET R2=0; elseif R1-ET>=V R2=R1-ET-V; end end
Can anyone help me in building this small simulink model?

回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2013 年 8 月 22 日

0 投票

You can call the function using any one of three MATLAB Function blocks.

この質問は閉じられています。

製品

質問済み:

2013 年 8 月 22 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by