Azzera filtri
Azzera filtri

How do I make a function to plot a given number of graphs(from a user input) from 30 columns of data?

1 visualizzazione (ultimi 30 giorni)
So I have a matrix L, which has 30 columns of data. I want to make a function which will be something like composite_plot_tsd(L,y). Where y is the number of graphs I want the 30 columns of data to be plotted on. So far I have this:
function [y] = composite_plot_tsd(L,y)
n=30;
ncols = ceil(30/y); % columns per plot
for i = 1:y
figure
kstart = (i-1) * ncols+1;
kend = min(kstart + ncols-1 ,n);
for j = kstart:kend
plot(L(:,j)),hold on
end
end
So for example if I used the function composite_plot_tsd(L,9), it would plot the 30 columns of data onto 9 separate figures. However the problem with my code is that with a number that isn't divisible by 30 it only plots onto 8 figures. I was hoping someone could help me correct my code and guide me in the right direction.

Risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by