GUI pop up menu plot data
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi at all
I'm new on matlab and especially on GUI;
I want to creat a GUI with a pup up menu plus a graph where I want plot data from matrix that I have already in my workspace;
Ok I understand how I can built that but, I've the follow problem:
In the pop up menu I have 3 options, option 1 option 2 and option 3;
depending of the option I want plot in a graph with data from the matrix 'A' or B or C depending on the option on the popup menu, I chose;
Matrixs A,B C are already on my workspace and coming as a resoult of other script connected with the push botton...
regarding the pop up menu:
I get 3 resoult as a variable a=1,2or 3 as below:
a=get(handles.popupmenu,'value') and thi work properly,
but when I chose to plot A B or C value is like the matrix are unknown....
how Can I solve that problem????
0 Kommentare
Antworten (1)
Luna
am 28 Nov. 2018
Bearbeitet: Luna
am 28 Nov. 2018
Hi,
The problem is they are unknown you are inside a different callback function so your workspace changes. Share your code, and we will see what is missing.
You should be passing your A,B,C matrices into the function that you are placing the plots.
4 Kommentare
Luna
am 29 Nov. 2018
Bearbeitet: Luna
am 29 Nov. 2018
where did you created td109,td110,td111 matrices first?
Use setappdata function like below:
setappdata(figObj,'MatrixA',A) % assign this MatrixA data into the main figure obj.
setappdata(figObj,'MatrixB',B)
And then call getappdata inside the callback function before your if-else block.
a=get(handles.popupmenu2,'value')
figHandle = gcf; % get the main figure
% if you have defined a tag for your main fig then use findobj function to get figure handle.
% ex: figHandle = findobj('Tag','myMainFigure');
td109 = getappdata(figHandle,'MatrixA'); % get the Matrix A info back
td110 = getappdata(figHandle,'MatrixB');
if (a==1)
plot(td109(:,8),td109(:,6));
elseif
(a==2)
plot(td110(:,8),td110(:,6))
else
(a==3)
plot(td111(:,8),td111(:,6))
end
Siehe auch
Kategorien
Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!