How to use external function to plot a graph in GUI or app designer

조회 수: 6 (최근 30일)
Saeid
Saeid 2020년 12월 5일
편집: Cris LaPierre 2020년 12월 11일
Currently I can only write the plotting command inside the code view of my GUI form. In cases where I need to write multiple commands for plotting it could better to have an external function that plots the graphs into the GUI form.
function PlotToGui
app.UIAxes.Plot (x,y)
end
but nothing happens in my app form. What am I doing wrong?

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 12월 5일
편집: Cris LaPierre 2020년 12월 11일
A couple things stand out. First, your function has no inputs, so app, x, and y do not exist within the scope of your function. Next, your syntax for plotting in an app is incorrect. See here.
Once your syntax is fixed, just make sure your plotting function is either in the same folder as the app or on you MATLAB Path. See here for more.
With an app, there is no need to define an external function .You can create helper functions inside the app.
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 12월 5일
Next, your syntax for plotting in an app is incorrect
Well, just "very likely" wrong. There is always a possibility that the user created a property named UIAxes that has either a method named Plot or a field that happens to contain the handle of a function. Users have done stranger things ;-)

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

추가 답변 (0개)

카테고리

Help CenterFile 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!

Translated by