matlab GUI, getting variables from other functions.

조회 수: 4 (최근 30일)
Kartavya
Kartavya 2014년 4월 21일
답변: Image Analyst 2014년 4월 22일
Hi, I have GUI created with multiple push buttons and multiple variables.
Here is the senario: The user edits the input and presses the button 1, the variable x and y gets filled with proper equations and it creates a plot.
However, I want the option of changing the plots using different push buttons. Ex: button 2 shows integral plot, button 3 shows derivative. But the problem I'm having is that x and y were defined using the push button 1 and I need to allow that information to be used under the call function of button 2 and 3.
  댓글 수: 1
Andreas Justin
Andreas Justin 2014년 4월 22일
편집: Andreas Justin 2014년 4월 22일
You mean something like this?
  • doc setappdata / doc getappdata
  • doc guidata
%%1
fig = figure;
handles = guihandles(fig); % @doc do not overwrite the handles structure
% or your GUI will no longer work
handles.Variables.X = 1;
handles.Variables.Y = 2;
guidata(fig, handles);
handles = guidata(fig);
X = handles.Variables.X;
Y = handles.Variables.Y;
%%2
fig = figure;
setappdata(fig,'X',1);
setappdata(fig,'Y',2);
X = getappdata(fig,'X');
Y = getappdata(fig,'Y');

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

답변 (1개)

Image Analyst
Image Analyst 2014년 4월 22일

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by