Reputation: 1
x = [1 3 4 6 9];
y = x + 3;
stem(x); xlabel('My x axis'); ylabel('My y axis'); title('No title --:)');
grid on;
hold on;
stem(y);
i have 8 graphs that are made using this format, i am trying to have them appear into 2 windows with 4 graphs on each, when i try to make a new file using subplot the graphs look completely different. what am i doing wrong?
image 1 is the correct graph image 2 is me trying to put it into subplot
x = [1 3 4 6 9];
y = x + 3;
subplot(2,2,1), plot(x,y)
Upvotes: 0
Views: 102
Reputation: 2035
You need 2 loops. One loop for figures, another loop for subplots within each figure:
for i = 1:2
figure; % this creates a separate figure
for j=1:4
subplot(2,2,j);
x = randi(10, 1, 4);
y = x + 3;
stem(x); xlabel('My x axis'); ylabel('My y axis'); title('No title');
grid on;
hold on;
stem(y);
end
end
Upvotes: 1