Filter löschen
Filter löschen

how to specify the axis area to my own function?

2 Ansichten (letzte 30 Tage)
xd h
xd h am 28 Feb. 2022
Beantwortet: Simar am 4 Okt. 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?

Antworten (1)

Simar
Simar am 4 Okt. 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

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by