How to read everything in file and make each a subplot

2 visualizzazioni (ultimi 30 giorni)
I have like 10 files (.mat) in a folder that all need to be read
and i wrote the code for the plotting
but i want to make it plot graphs for all the 10 files and make subplots and show up as one
i think i should do a loop but not sure how to make the subplots

Risposta accettata

Star Strider
Star Strider il 23 Giu 2016
Modificato: Star Strider il 23 Giu 2016
Reading your files in a loop depends on what is in them and how you have named them. Without more information, it is not possible to write that code.
One approach to the plots:
x = 0:19; % Create Data
y = randi(9, 10, 20); % Simulate ‘.mat’ File Inputs
for k1 = 1:size(y,1)
subplot(5, 2, k1) % Create 5-Row x 2-Column Array Of Subplots
plot(x, y(k1,:))
grid
title(sprintf('Subplot #%d', k1))
end
  1 Commento
Star Strider
Star Strider il 23 Giu 2016
This will probably work:
cmPer=5.7/362;
secPer=1/30;
t=secPer*[1:360*30];
for k1 = 1:size(y,1)
subplot(5, 2, k1) % Create 5-Row x 2-Column Array Of Subplots
v=cmPer*data.speed;
plot(t, v)
grid
title(sprintf('Subplot #%d', k1))
end
I have no idea what ‘data.speed’ is or what it contains. Consider referring to it as:
v=cmPer*data(k1).speed;
if you have read all your data from all your files into your ‘data’ structure. I still have no idea how you are doing that.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by