Clear Filters
Clear Filters

Send plots from matlab script to UIAxes in Appdesigner

27 views (last 30 days)
Hello,
at the moment im working with Matlab App Designer, therefore I use a lot of Matlab Scripts which I programmed before. With Appdesigner I just made a GUI that it's easier to use all of them. The only thing I do is to open the different matlab scripts and run them when I push the Start Button. Everything works fine. My only problem is that I have a own Script which makes different plots depending on some adjustments. I don't want to program it in App Designer because than there would be a way to much code with if functions and I'm afraid that it's to confusing than and you get lost easily. With said Script I always get just one plot. And now I want to know how i can put this plot into a UIAxes from AppDesigner, because at the moment it always opens a own figure.
Following are some lines of this script for the plot.
I hope you can help me.
Whith best regards.
% Benötigte Koordinaten für Schulter mit Punkten hervorheben
if isequal(werte.config.Koerperteil,'Schulter')
if isequal(werte.config.Seite,'Rechts') || isequal(werte.config.Seite,'Links')
plot(RShoulder(1), RShoulder(2), 'y+', 'LineWidth', 2, 'MarkerSize', 15);
plot(Neck(1), Neck(2), 'y+', 'LineWidth', 2, 'MarkerSize', 15);
plot(LShoulder(1), LShoulder(2), 'y+', 'LineWidth', 2, 'MarkerSize', 15);
end
% Benötigte Koordinaten für Ellenbogen hervorheben
elseif isequal(werte.config.Koerperteil,'Ellenbogen')
if isequal(werte.config.Seite,'Rechts')
plot(RShoulder(1), RShoulder(2), 'y+', 'LineWidth', 2, 'MarkerSize', 15);
plot(RElbow(1), RElbow(2), 'y+', 'LineWidth', 2, 'MarkerSize', 15);
plot(RWrist(1), RWrist(2), 'y+', 'LineWidth', 2, 'MarkerSize', 15);
elseif isequal(werte.config.Seite,'Links')
plot(LShoulder(1), LShoulder(2), 'y+', 'LineWidth', 2, 'MarkerSize', 15);
plot(LElbow(1), LElbow(2), 'y+', 'LineWidth', 2, 'MarkerSize', 15);
plot(LWrist(1), LWrist(2), 'y+', 'LineWidth', 2, 'MarkerSize', 15);
end

Accepted Answer

Ajay Kumar
Ajay Kumar on 3 Oct 2019
Edited: Ajay Kumar on 3 Oct 2019
Try to create an axes in app designer using uiaxes. example: ax = uiaxes(....)
Then, when plotting pass this ax as first parameter to plot. example: plot(ax,......)
Now, the plot will not open a new figure, but it plots in the axes created in app designer.
doc plot
see example:
plot(ax,___) creates the line in the axes specified by ax instead of in the current axes (gca). The option ax can precede any of the input argument combinations in the previous syntaxes.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer 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!