plot in UIAxes from a matlab function

조회 수: 3 (최근 30일)
Marco Picillo
Marco Picillo 2021년 3월 30일
댓글: Marco Picillo 2021년 3월 31일
Hi, i created a function in matlab that plots a graph giving some inputs. i want to put this function in my GUI and show the graph in the GUI. How can i do that?
At this moment the function runs in the GUI, but the plot it's shown in a figure, not in the UIFigure, how can i fix this problem?
thank you!

채택된 답변

Adam Danz
Adam Danz 2021년 3월 30일
You have to specify the axis handle as the parent of your plotting function. See example.
  댓글 수: 5
Adam Danz
Adam Danz 2021년 3월 31일
I see that this is a plotting function.
It is good practice to include a parent handle in the inputs of plotting functions so that all internal plotting commands can act on the specified axes/figure/etc.
For example,
function plotsomething(inp1,inp2,axisHandle)
fill3(axisHandle, . . .)
set(axisHandle, . . .);
view(axisHandle, . . .);
axis(axisHandle, 'equal');
hold(axisHandle, on)
xlabel(axisHandle,'x-coordinate')
% etc....
end
Then call the function from your app using,
plotsomething(x,y,app.UIAxes) % except use YOUR axis handle!
Marco Picillo
Marco Picillo 2021년 3월 31일
thank you so much!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by