i need to plot many plots in a loop function.

1 view (last 30 days)
function data=coa08xxx_lines(n)
load xydata
for u=X(:,n)
for i=Y(:,n)
data= plot(u,i);
end
end
end
This code only plots the graph of n, but i want it to plot all the graps. for example if n=3, then i want the plot of 3, 2 and 1 to appear as subplots.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 15 Nov 2013
Edited: Azzi Abdelmalek on 15 Nov 2013
function data=coa08xxx_lines(n)
load xydata
ii=ceil(n/3);
jj=ceil(n/ii);
for k=1:n
subplot(ii,jj,k)
plot(u(:,k),y(:,k));
end
  5 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 15 Nov 2013
function data=coa08xxx_lines(n)
data=load('xydata');
%If xydta contains x and y variables
y=data.Y;
u=data.X;
ii=ceil(n/3);
jj=ceil(n/ii);
for k=1:n
subplot(ii,jj,k)
plot(u(:,k),y(:,k));
end
vishant m.
vishant m. on 15 Nov 2013
Edited: vishant m. on 16 Nov 2013
That works,thanks alot. but can you give me a brief explanation of how it works. The code also works only when n=<9 , i want it to ignore n if n>9 and just plot n=9.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!