GUI pop up menu plot data

3 次查看(过去 30 天)
ADC
ADC 2018-11-28
编辑: Luna 2018-11-29
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????

回答(1 个)

Luna
Luna 2018-11-28
编辑:Luna 2018-11-28
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 个评论
Luna
Luna 2018-11-29
编辑:Luna 2018-11-29
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by