Effacer les filtres
Effacer les filtres

how to change axes in loops

4 vues (au cours des 30 derniers jours)
Mirza M
Mirza M le 25 Nov 2014
Modifié(e) : Adam le 25 Nov 2014
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?

Réponses (1)

Adam
Adam le 25 Nov 2014
Modifié(e) : Adam le 25 Nov 2014
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.

Catégories

En savoir plus sur Lighting, Transparency, and Shading dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by