I am trying to move through a series of images in a GUI but receive the following error when pressing the 'next block' button following the load button. The 'next block' button should display on the two axes on the screen the next 2 figures
{Error: Struct contents reference from a non-struct array object.
Error in Block_Sort>next_block_Callback (line 93) a1 = axes(handles.axes1);
Error in gui_mainfcn (line 95) feval(varargin{:});
Error in Block_Sort (line 42) gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Block_Sort('next_block_Callback',hObject,eventdata,guidata(hObject)) 93 a1 = axes(handles.axes1);
} function next_block_Callback(hObject, eventdata, handles)
% hObject handle to next_block (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
images = guidata(hObject);
a1 = axes(handles.axes1);
a2 = axes(handles.axes2);
for i = 1:length(images)
I = images{i+1};
J = images{i+2};
imshow(a1,I);
imshow(a2,J);
end
function load_Callback(hObject, eventdata, handles)
% hObject handle to load (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
addpath(pwd)
animal = evalin('base','animal');
foldname = ['Selected-Figures-' animal '*'];
filename = dir(foldname);
dinfo = dir(filename.name);
addpath(filename.name);
names_cell = {dinfo.name};
names_cell = names_cell(3:end);
images = cell(1,length(names_cell));
for i = 1:length(names_cell)
curr_file_name = names_cell{i}; curr_im = imread(curr_file_name); images{i} = curr_im;
end
guidata(hObject,images);
I = imread(names_cell{1});
I = imresize(I,2);
J = imread(names_cell{2});
J = imresize(J,2);
axes(handles.axes1);
imshow(I);
axes(handles.axes2);
imshow(J);
Best Answer