App designer not working same as Matlab providing the same code

2 ビュー (過去 30 日間)
Victor
Victor 2024 年 3 月 6 日
編集済み: Victor 2024 年 3 月 7 日
Hi, I am working on a project, which solve state-space representation with for loop. Here is my code:
------------------------------
--------------------------------
This code is working fine every time I run it. The plot is the same every time I run the code (obviously :))) ). However, when I put this code in to App Designer like this:
-------------------------------
---------------------------------------------
Every time I press the button, the plot is slightly different. Around 10 times, the graph ends up looking very different from the one which runs in matlab. You can test the code with a constant U value and it works fine with that :D.
I suspect that the variables I declared are not fully reset after each time I run, as the result, the plot would look different. Can anyone take a look at my code? Thanks very much and I am really appreciated. If you need more details about this problem, just let me know :D

回答 (1 件)

Austin M. Weber
Austin M. Weber 2024 年 3 月 6 日
I think you are right that your plot isn't being properly reset after each time you press the button. Try adding:
cla(app.UIAxes) % Clear current axes
as the first line in your StartsimulationButtonPushed function. Hopefully that fixes your problem.

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by