GUIDE - guidata not working
조회 수: 2 (최근 30일)
이전 댓글 표시
Dear all; I don't have much of experience with guide so what I'm asking might be a real silly issue... I have a simple GUI in which I have a drop down menu and a table. Depending of what is chosen in the drop down menu, the first column of the table should be updated with different entries (Data1, Data2...) so that the user can fill the second column with the corresponding values for Data1, Data2 and so on... Now, I'm having problems with shared variables. The variable I want to share is handles.StraightPipe as this is supposed to hold the values for the first column of the table (the scrips is not ready to accomplish this yet). Now, if I move handles.StraightPipe around I can see its output on the editor unless I move it after function varargout, if that happens nothing is written on the editor meaning that at this point the variable is not recognized anymore and I don't undestand why.
Any help would be really appreciated
Here's my script:
function varargout = testToolbox(varargin)
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @testToolbox_OpeningFcn, ...
'gui_OutputFcn', @testToolbox_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before testToolbox is made visible.
function testToolbox_OpeningFcn(hObject, eventdata, handles, varargin)
handles.StraightPipe = {'Straight_diameter';'Straight_length1';'Shape'};
handles.Turn = {'Turn Angle','Turn Diameter'};
handles.output = hObject;
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = testToolbox_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
%--- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
%something goes here
% --- Executes during object creation, after setting all properties.
function uitable1_CreateFcn(hObject, eventdata, handles)
set(hObject,'ColumnName','Value','RowName',{'a';'b';'c'},'Data',{blanks(0);blanks(0);blanks(0)});
댓글 수: 2
답변 (2개)
Tom
2013년 6월 26일
It doesn't work because you're changing the handle itself, so the program can no only reference the controls. I'm guessing you should be doing something like this:
set(handles.StraightPipe,'String',{'Straight_diameter';'Straight_length1';'Shape'});
set(handles.Turn,'String'({'Turn Angle','Turn Diameter'});
댓글 수: 4
Tom
2013년 6월 26일
Looking at your code, what are StraightPipe and StraightDiameter meant to be? I assumed they were uicontrols, but they seem to be called popupmenu1 and uitable1.
참고 항목
카테고리
Help Center 및 File Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!