Step plot app designer

3 ビュー (過去 30 日間)
Victor Castro Campos
Victor Castro Campos 2020 年 8 月 23 日
回答済み: Rahul 2024 年 9 月 4 日
How Can I plot a step function in app designer? When I use UIAxes gives me an error.
  2 件のコメント
Adam Danz
Adam Danz 2020 年 8 月 23 日
The full error message would tell us what's wrong.
Knowing how you're plotting the step function would also be helpful.
Pierre-Olivier Desrosiers
Pierre-Olivier Desrosiers 2022 年 10 月 4 日
Hi Victor, if you're using a simulink model, you can just add a To Workspace block, sim() your model, then you will have access to your step function values. Also, about the UIAxes, that's what you'll need to write :
plot(app.Name_of_your_Uiaxes(UIAxes by default), x_value, y_value);
Hope that helps.

サインインしてコメントする。

回答 (1 件)

Rahul
Rahul 2024 年 9 月 4 日
I understand that you are trying to plot a step function in app designer using 'UIAxes' component of app designer.
To achieve the desired result you can follow the following steps:
  • Add a 'UIAxes' component to the 'UIFigure' of the app
  • Add a push Button component to the 'UIFigure'
  • Add a 'ButtonPushed' callback on this Button.
  • In the 'ButtonPushed' callback of the added button add the folloing code
x = 0:5;
y = [0, 1, 1, 2, 2, 3];
stairs(app.UIAxes,x,y)
% You can change x and y according to your use-case change the name of your
% app in the 'stairs' functions
In the above mentioned case you are needed to add a push Button and it's callback.
If that is not desirable, then a possible workaround can be
  • Export the app as a '.m' file
  • Open the exported '.m' file
  • Add the step function code mentioned above in 'createComponents' function after setting the position of the 'UIAxes'
  • Run the app from MATLAB editor
  • You will get the plotted step function on the 'UIAxes' directly after running the app.
Hope this helps! Thanks.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by