How to read everything in file and make each a subplot
조회 수: 6 (최근 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
댓글 수: 0
채택된 답변
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
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개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!