i have two buttons to search different directories but the second button cant add more variables to the guidata
1 view (last 30 days)
Show older comments
steven Garcia
on 3 Oct 2014
Commented: Star Strider
on 4 Oct 2014
function pushbutton5_Callback(hObject, eventdata, handles)
symbol=char(92);
dirControl = uigetdir;
dirControl= strcat(dirControl,symbol);
controlfiles=dir([dirControl '*.img']);
for i = 1:numel(controlfiles)
file= strcat(dirControl,controlfiles(i).name,',1');
imcell{1,1} =(file);
end
handles.imcellG1=imcell;
handles.DirectorioG1=dirControl;
guidata(hObject, handles)
function pushbutton6_Callback(hObject, eventdata, handles)
symbol=char(92);
dirControl = uigetdir;
dirControl= strcat(dirControl,symbol);
controlfiles=dir([dirControl '*.img']);
for i = 1:numel(controlfiles)
file= strcat(dirControl,controlfiles(i).name,',1');
imcell{1,1} =(file);
end
handles.imcellG2=imcell;
handles.DirectorioG2=dirControl;
guidata(hObject, handles2)
Accepted Answer
Star Strider
on 3 Oct 2014
I didn’t run your code, but just from observation it seems that if ‘imcell’ has not been created, your ‘controlfiles’ array has zero elements. (Something about either assignment of ‘dirControl’ is probably not correct.) The loop is not iterating.
2 Comments
More Answers (1)
Geoff Hayes
on 4 Oct 2014
Steven - in your second callback, look closely at the guidata call
guidata(hObject, handles2)
The second parameter is named handles2 whereas all of your code is updating handles. (I'm surprised that an error isn't thrown because of the invalid variable name.) Just change this line to
guidata(hObject, handles);
and try again.
0 Comments
See Also
Categories
Find more on Whos in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!