Use of nested function in MATLAB app designer
古いコメントを表示
I want to access data and use for mutiple push buttons to plot graphs. For ImportdataButtonPushed import the data then for torqueButtonPushed I want to access and use data which imported in Import push button.
% Button pushed function: torqueButton
function torqueButtonPushed(app, event)
plot(app.UIAxes,[A.Speed_1_Total_WT1],[A.Torque_1_Total_WT1])
plot(app.UIAxes,[A.P_SigmaA_Total_WT1],[A.Eta1_1_Total_WT1])
However when I tried to plot graph it gives me error and I unable to plot subplot. Otherwise I have to add ten push buttons for ten plots. Using nested function how can use data to plot graph?
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 410)
Error while evaluating Button PrivateButtonPushedFcn.
12 件のコメント
Rik
2021 年 6 月 22 日
What is the complete error message?
It looks to me like you should store the loaded data in a private property. The you can simply use app.A.Torque_1_Total_WT1 to load the data. (I would also recommend changing the name of that variable; it looks like you're storing data in variable names, instead of in variables. Use index arrays instead: app.A.Torque{1}.Total_WT{1})
Rik
2021 年 6 月 22 日
AppDesigner apps are based on uifigure. That means you will have to use explicit handles in most cases, and some functions will not work at all, as they have to be implemented separately.
Arshey Dhangekar
2021 年 6 月 22 日
Rik
2021 年 6 月 22 日
Now you have even deleted the little code you did post. Are you using explicit handles yet?
Arshey Dhangekar
2021 年 6 月 22 日
編集済み: Arshey Dhangekar
2021 年 6 月 22 日
Rik
2021 年 6 月 22 日
Please post your code.
Arshey Dhangekar
2021 年 6 月 22 日
Rik
2021 年 6 月 22 日
Your question is not clear to me. You seem to be well aware how to change the axis labels, as you do so multiple times in this code. What is your specific issue?
Arshey Dhangekar
2021 年 6 月 22 日
Rik
2021 年 6 月 23 日
What do you want? Multiple axes with one graph each? Or one axis that shows one graph at a time? You seem to have implemented the first option. The second option seems easy enough to implement: move all the label setting to the callback functions.
Arshey Dhangekar
2021 年 6 月 23 日
編集済み: Arshey Dhangekar
2021 年 6 月 23 日
Rik
2021 年 6 月 23 日
That doesn't answer my question.
What do you want? 10 axes, or 1? The total in either case would be 10 graphs.
And what part do you want to automate? You can write a small function that will create a uiaxes object and a button, but you will still have to type the text itself. Is that what you would want?
Try to make it easy for me to help you. It is easy for me to ignore this thread if it is more frustrating than rewarding. I doubt that is what you want.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Develop Apps Using App Designer についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!