How to read everything in file and make each a subplot

2 次查看(过去 30 天)
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

采纳的回答

Star Strider
Star Strider 2016-6-23
编辑:Star Strider 2016-6-23
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 个评论
Star Strider
Star Strider 2016-6-23
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.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by