how to clear axis in for loop?

조회 수: 1 (최근 30일)
preeti
preeti 2015년 5월 12일
댓글: preeti 2015년 5월 13일
Hi,I have an output Panel where the images are shown .At a time 25 images can be shown.But sometimes the axes are partially filled by images and I want to delete the empty axes.Suppose 3 images are present and rest of axis are empty the code is shown below for it. This is my code:-
> m=1;%for first axes
for i=4:25
cla(handles.(['axes',num2str(m+1)]));
m=m+1;
end
whats wrong here clearing only one axes? end
  댓글 수: 3
preeti
preeti 2015년 5월 12일
ya set(ax, 'Visible','off') can work but dont know its working with for loop..
preeti
preeti 2015년 5월 13일
@Walter pls suggest some nice soln..

댓글을 달려면 로그인하십시오.

답변 (2개)

Thomas Koelen
Thomas Koelen 2015년 5월 12일
Why would you use m instead of just using the i you already specified in your for loop?
For further work don't use i or j as variables because i and j are both functions denoting the imaginary unit:
So a variable called i or j will override them, potentially silently breaking code that does complex maths.
for your problem, you forgot a strcat, try again with
strcat('axes',num2str(i))
  댓글 수: 2
Walter Roberson
Walter Roberson 2015년 5월 12일
strcat(A,B) is not needed when you use [A,B]
Thomas Koelen
Thomas Koelen 2015년 5월 12일
편집: Thomas Koelen 2015년 5월 12일
Never knew, I'm still new to matlab and didn't know you could do it like this :) Also had no computer to check it at the moment.

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2015년 5월 13일
If your axis might contain some items with invisible handles and you want to get rid of the items, then you need to pass the 'reset' option to cla()
cla(handles.(['axes',num2str(m+1)]), 'reset');
  댓글 수: 1
preeti
preeti 2015년 5월 13일
Sir , I just need to clear axis that are empty in the output panel and sry to say reset not clearing axis in matlab.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by