Borrar filtros
Borrar filtros

creating several subplots with for loop

3 visualizaciones (últimos 30 días)
Thomas Fogarty III
Thomas Fogarty III el 26 de Feb. de 2016
Comentada: Thomas Fogarty III el 28 de Feb. de 2016
I'm trying to take data that is 86 rows long and generate a series of subplots. The code would generate 5 subplots per figure and repeat such that the first would be rows 1-5, second rows 6-10, etc. Ex.
Fig1
a = row 1
b = row 2
c ...
e = row 5
I have been able to generate this plot manually for 5 rows at a time; i want to loop this script to generate sets of 5 subplots per figure until all rows have been plotted.
The code I used to generate the 5 rows successfully is as follows:
start = 1
finish = 5
rows = finish - start
figure
for i = start:1:finish
hold on
subplot(rows+1,1,i);
plot(chan1(i,2:end));
end
Any suggestions on how to expand this to run all the data at once would be greatly appreciated!

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 26 de Feb. de 2016
t=1:100;
y=rand(80,100);
for k=1:5:size(y,1);
s=y(k:k+4,:);
figure;
for ii=1:5
subplot(5,1,ii);
plot(t,s(ii,:))
end
end
  1 comentario
Thomas Fogarty III
Thomas Fogarty III el 28 de Feb. de 2016
thanks - looks like it works perfectly! much appreciated!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by