From: megha bhatt on
Hello,
My image is quite big with axis latitude and longitude, I want to plot the image at once and to show the position I am interested in, I want to plot a red star within a for loop and generate its spectra. If I plot the image every time inside loop the program becomes very slow so I took the image plotting part outside the loop, the code is given below:
figure()
subplot(1,2,1);
imshow(img.rad(:,:,2),'Border','tight','DisplayRange'[img.mindrange,img.maxdrange],'XData', img.xlims,'YData',img.ylims)
axis on;axis xy;
for i=1:length(test1)
hold on
set(h,'yLim',[sirll(i,2)-2 sirll(i,2)+2])
plot(sirll(i,1),sirll(i,2),'r*','MarkerSize',10)
hold off
subplot(1,2,2)
plot(comb_w,,test1(i,:),'r-','linewidth',2)
pause(0.1)
end
The code is working but the hold on command hold the previous red star as well, in fact I want to see a new position showed by red star in each iteration.
If I don't use 'Hold on' then the image also disappear and only the star is moving on a blank figure.
Any suggestion about keeping the image as it is and changing its limits each time in the loop and plotting a new position denoting by star?
Thanks,
Megha
From: megha bhatt on
Got the answer...
The code is modified as below in order to solve the problem:
subplot(1,2,1);
imshow(img.rad(:,:,2),'Border','tight','DisplayRange'[img.mindrange,img.maxdrange],'XData', img.xlims,'YData',img.ylims)
axis on;axis xy
hold on; hplot=[];
for i=1:length(polyrefl.orb(x,1).sir)
subplot(1,2,1)
ylim([sirll(i,2)-2 sirll(i,2)+2]);
delete(hplot)
hplot=plot(sirll(i,1),sirll(i,2),'r*','MarkerSize',10);
subplot(1,2,2)
plot(comb_w,,test1(i,:),'r-','linewidth',2)
pause(0.1)
end

Regards,
Megha
"megha bhatt" <mubhatt19(a)yahoo.co.in> wrote in message <hqjmkq$sep$1(a)fred.mathworks.com>...
> Hello,
> My image is quite big with axis latitude and longitude, I want to plot the image at once and to show the position I am interested in, I want to plot a red star within a for loop and generate its spectra. If I plot the image every time inside loop the program becomes very slow so I took the image plotting part outside the loop, the code is given below:
> figure()
> subplot(1,2,1);
> imshow(img.rad(:,:,2),'Border','tight','DisplayRange'[img.mindrange,img.maxdrange],'XData', img.xlims,'YData',img.ylims)
> axis on;axis xy;
> for i=1:length(test1)
> hold on
> set(h,'yLim',[sirll(i,2)-2 sirll(i,2)+2])
> plot(sirll(i,1),sirll(i,2),'r*','MarkerSize',10)
> hold off
> subplot(1,2,2)
> plot(comb_w,,test1(i,:),'r-','linewidth',2)
> pause(0.1)
> end
> The code is working but the hold on command hold the previous red star as well, in fact I want to see a new position showed by red star in each iteration.
> If I don't use 'Hold on' then the image also disappear and only the star is moving on a blank figure.
> Any suggestion about keeping the image as it is and changing its limits each time in the loop and plotting a new position denoting by star?
> Thanks,
> Megha