MATLAB: Easy Question froma beginner

beginnersubplot

Hi all,
I've registered just to ask this little question. Im sure theres a very simple fix for this but i cant seem to find it.
Im trying to write an m-file, without going into much detail, where im stuck is; well i want matlab to plot like 4 plots (2×2 with subplot) if the input is 4 files. Or or subplot its with 8×10 is the user chooses 80 files.
Is there a function that can do it?
I can only plot a certain number of enteries like this. I would greatly appreciate it if you could help me out.

Best Answer

n=80
t=0:0.1:10;
y=sin(t);
m1=ceil(sqrt(n))
m2=ceil(n/m1)
for k=1:n
subplot(m1,m2,k);
plot(t,y)
end