how to change axes in loops

4 次查看(过去 30 天)
Mirza M
Mirza M 2014-11-25
编辑: Adam 2014-11-25
i want to change axes so i can show images in different axes. here is my code
n = 13;
for m = 1:n
for idfile = 1:indSim(m)
if idfile < 10
name_file = strcat('000',num2str(idfile));
elseif idfile < 100
name_file = strcat('00',num2str(idfile));
elseif idfile < 1000
name_file = strcat('0',num2str(idfile));
else
name_file = strcat(num2str(idfile));
end
end
str_img_name = strcat(folder, name_file, '.jpg');
returned_img = imread(str_img_name);
axes(handles.axes(m));
imshow(returned_img);
end
but i've got an error like this 'Reference to non-existent field 'axes'.' how can i change axes depends on `m` in the loops?

回答(1 个)

Adam
Adam 2014-11-25
编辑:Adam 2014-11-25
Your axes will each have a 'Tag'. If you used Guide to create your GUI which I am guessing you did from the 'handles' usage then you will need to gather the axes handles together into an array by accessing them as e.g.
handles.hAxes = [ handles.axes1, handles.axes2, handles.axes3 ];
Then use
axes( handles.hAxes(m) )
to change axes.
Personally I favour:
imshow( returned_img, 'Parent', handles.hAxes(m) );
rather than explicitly changing the current axes with:
axes( handles.hAxes(m) )
but that should work too.

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by