Effacer les filtres
Effacer les filtres

i have two buttons to search different directories but the second button cant add more variables to the guidata

2 vues (au cours des 30 derniers jours)
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)

Réponse acceptée

Star Strider
Star Strider le 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.

Plus de réponses (1)

Geoff Hayes
Geoff Hayes le 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.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by