Effacer les filtres
Effacer les filtres

how to use variable outside the for loop

2 vues (au cours des 30 derniers jours)
singh
singh le 25 Avr 2015
Commenté : singh le 25 Avr 2015
suppose i use for loop and this is code
N=20;
area=100;
X=rand(1,N)*area;
Y=rand(1,N)*area;
htext=[];
for i1=1:2
for i=1:N
htext(i)=text(X(i),Y(i),num2str(i),'fontsize',20);
hold on
end
end
delete(htext)
for ii=1:5
delete(htext(ii));
end
now error is come when delete(htext) is execute plz give me some solution.
beacuse it show the message when cursor move on the htext variable 'htext size will be change every iteration '.how to delete hetxt value in for loop and out of for loop
  2 commentaires
Jan
Jan le 25 Avr 2015
Please post the complete error message in every case. A rough summary is not useful in the forum. Thanks.
singh
singh le 25 Avr 2015
jan simon see this pic.

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 25 Avr 2015
for i=1:5
htext(i)=text(X,Y,num2str(i));
end
pause(1)
delete(htext)
delete can delete the complete vedtor in on step without a loop.
  1 commentaire
singh
singh le 25 Avr 2015
jan,thnks for solution

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by