Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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)

Respuesta aceptada

Star Strider
Star Strider el 3 de Oct. de 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.

Más respuestas (1)

Geoff Hayes
Geoff Hayes el 4 de Oct. de 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.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by