필터 지우기
필터 지우기

how to specify the axis area to my own function?

조회 수: 2 (최근 30일)
xd h
xd h 2022년 2월 28일
답변: Simar 2023년 10월 4일
I define a function to get a graph.
I design an app and need to call my defined function. But it can't draw in the app axis area, but a new separated figure.
How to draw the graph in my app with my defined function?

답변 (1개)

Simar
Simar 2023년 10월 4일
Hi xd h,
I understand that you are unable to draw in the app axis and plotting a graph in app with your defined function.
You can do the same by modifying your function to accept the axes handle as an input argument. Then, when you call this function from your app, pass the axes handle of the app to the function. Here is an example of how one can do it:
Let us assume a function called myFunction that plots a graph, modify it to accept an axes handle:
function myFunction(ax)
% Your code here
% For example, let us plot a simple graph
plot(ax, 1:10, rand(1, 10));
end
In app, call this function and pass the axes handle:
% Assuming your axes handle is app.UIAxes
myFunction(app.UIAxes);
The function myFunction takes an axes handle (ax), and x and y data for plotting. When you call this function from within app and pass the handle of the app's axes (e.g., app.UIAxes), the function will plot the data on those specific axes.
This way, myFunction will plot the graph directly into the axes of your app. Make sure to replace app.UIAxes with the actual name of your axes handle.
I hope this helps !
Best Regards,
Simar

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by