Use of nested function in MATLAB app designer

조회 수: 16 (최근 30일)
Arshey Dhangekar
Arshey Dhangekar 2021년 6월 21일
댓글: Rik 2021년 7월 1일
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
Arshey Dhangekar
Arshey Dhangekar 2021년 6월 23일
편집: Arshey Dhangekar 2021년 6월 23일
I want to plot 10 graphs with two axes. One axis that shows one graph at a time Like x1 vs y1, x2 vs y2 ..... x10 vs y10. It is fine I can type name of axis label.
Rik
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Rik
Rik 2021년 6월 23일
You can use the callback functions of your buttons to replace the graphs and labels:
function torquevsSpeedButtonPushed(app, event)
plot(app.UIAxes,app.A.Torque_1_Total_WT1,app.A.Speed_1_Total_WT1)
title(app.UIAxes, 'Speed vs Torque vs Power')
xlabel(app.UIAxes, 'Speed (rpm)')
ylabel(app.UIAxes, 'Torque(Nm)')
zlabel(app.UIAxes, 'Z')
end
  댓글 수: 4
Arshey Dhangekar
Arshey Dhangekar 2021년 7월 1일
Just wondering how can plot histogram in matlab app designer?
Rik
Rik 2021년 7월 1일
You can either use histcounts and use bar, or you can use histogram. As with any GUI: make sure you specify your axes (or in your case uiaxes) as the parent object.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by