Reputation: 233
I want to show image and plot in the loop. I want to show image in one figure and plot in other figure. So I try to use my code, but it does not work. Could you help me fix it? Thanks so much
x=0;
x_arr=[]
I=imread('peppers.png');
figure
for i=1:100
if mod(i,10)==0
pause(0.5);
x=i.^2+1;
x_arr=[x_arr x]
%show image
hold on
imshow(I);
hold off
%show plot
pause(0.5);
hold on
plot(y_arr);
hold off
end
end
Upvotes: 0
Views: 1013
Reputation: 1390
you can do so by using figure for handeling 2 windows:
x=0;
x_arr=[]
I=imread('peppers.png');
for i=1:100
if mod(i,10)==0
pause(0.5);
x=i.^2+1;
x_arr=[x_arr x];
%show image
figure(1)
imshow(I);
%show plot
pause(0.5);
figure(2)
plot(x_arr);
end
end
or by using subplots to keep it in one window:
x=0; x_arr=[]
I=imread('peppers.png');
figure (1)
for i=1:100
if mod(i,10)==0
pause(0.5);
x=i.^2+1;
x_arr=[x_arr x] %show image
subplot(1,2,1);
imshow(I);
%show plot
pause(0.5);
subplot(1,2,2)
plot(x_arr);
end
end
Upvotes: 2