how to specify the axis area to my own function?

2 次查看(过去 30 天)
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