how to specify the axis area to my own function?
6 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Simar
on 4 Oct 2023
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
0 Comments
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!