필터 지우기
필터 지우기

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
Luna
Luna 2018년 11월 29일
Also see the links below:

댓글을 달려면 로그인하십시오.

카테고리

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