Effacer les filtres
Effacer les filtres

How to read everything in file and make each a subplot

6 vues (au cours des 30 derniers jours)
np
np le 23 Juin 2016
Commenté : Star Strider le 23 Juin 2016
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

Réponse acceptée

Star Strider
Star Strider le 23 Juin 2016
Modifié(e) : Star Strider le 23 Juin 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 commentaire
Star Strider
Star Strider le 23 Juin 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by