MATLAB: Subplots made by multiple plots

plotsubplot

Hi,
I would like to draw a figure consisting of 3 subplots, each made by 4 plots.
Here's my code, to make it more clear…
hold all;
for i=1:4
subplot(1,3,1);
plot(S1(:,1,i), S1(:,2,i), c(i));
xlim([0 1]);
subplot(1,3,2);
plot(S2(:,1,i), S2(:,2,i), c(i));
xlim([0 1]);
subplot(1,3,3);
plot(S3(:,1,i), S3(:,2,i), c(i));
xlim([0 1]);
end
hold off;
My problem is that only the last plots are drawn in the subplots. So I see only one line per subplot, instead of the 4 I intended. Can anyone help me fix this?
Thanks!

Best Answer

Each subplot needs to be held individually.
figure; hold on
subplot(121)
hold on
plot(1:3)
plot(rand(1,3))
subplot(122)
hold on
plot(4:6)
plot(rand(1,3))