how to change axes in loops
조회 수: 4 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!