can't plot using user-defined function block.
1 回表示 (過去 30 日間)
古いコメントを表示
I have a Matlab code to plot a graph. but when I used the same code in Simulink as a user-defined function, I am getting a lot of parellel lines instead of the desired graph in the scope block. does anyone know how to fix this?
2 件のコメント
madhan ravi
2019 年 2 月 21 日
編集済み: madhan ravi
2019 年 2 月 21 日
share your model with your user defined function
採用された回答
Fangjun Jiang
2019 年 3 月 29 日
編集済み: Fangjun Jiang
2019 年 3 月 29 日
Keep in mind that this MATLAB Function block is executed at every simulation step you run. Your funciton ouputs 201 values at every step and these values are the same from step to step. That is why your scope shows 201 straight lines.
If you want to plot sin(x). One way to do it is to add a Simulink "Clock" block and connect its output to "u". Inside your function, simply specify it as y=sin(u).
2 件のコメント
Fangjun Jiang
2019 年 4 月 1 日
Just remember that in Simulink, there is a "time" element. Everything goes along the simulated "time" once you press the "Run" button.
For the sake of plotting sin(x) in Simulink without time, you could use XY scope.
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!