Azzera filtri
Azzera filtri

how to specify the axis area to my own function?

2 visualizzazioni (ultimi 30 giorni)
xd h
xd h il 28 Feb 2022
Risposto: Simar il 4 Ott 2023
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?

Risposte (1)

Simar
Simar il 4 Ott 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

Categorie

Scopri di più su Specifying Target for Graphics Output in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by