フィルターのクリア

plot seperate measurements in for loop on the same graph

1 回表示 (過去 30 日間)
Debbie Oomen
Debbie Oomen 2017 年 10 月 9 日
編集済み: Jonathan Chin 2017 年 10 月 11 日
I have several measurements saved in one folder. All measurement files have the same two colums (column A is time(s) and column B is volt). I used this script:
myDir = uigetdir; %gets directory
myFiles = dir(fullfile(myDir,'*.xlsx')); %gets all xlsx in struct
for i = 1:length(myFiles(:,1));
sig= xlsread(myFiles(i).name, 'B:B');
time= xlsread(myFiles(i).name, 'A:A');
plot(time,sig(i))
However, the sig returns as the values of column B of all measurements and does not plot anything but I only want Matlab to loop through every file and then plot the separate measurements in one figure using multiple graphs per measurement.
  3 件のコメント
Debbie Oomen
Debbie Oomen 2017 年 10 月 10 日
Thank you. However, I now get two plots in the same figure and they are overwriting another. I want the plots for all my signals in different graphs so that each measurement can be seen beneath each other. How can I do this?
Jonathan Chin
Jonathan Chin 2017 年 10 月 11 日
編集済み: Jonathan Chin 2017 年 10 月 11 日
do you mean sub plots?
for i = 1:length(myFiles(:,1));
sig{i}= xlsread(myFiles(i).name, 'B:B');
time{i}= xlsread(myFiles(i).name, 'A:A');
subplot(length(myFiles(:,1)),1,i)
plot(time{i},sig{i})
end
subplot allows you to put multiple plots on the same figure.

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2017 年 10 月 10 日
files = dir('*.xlsx'); % get all excel files
N = length(files) ; % total number of files
figure
hold on
for ii = 1:N
[num,txt,raw] = xlsread(files(i).name) ;
plot(num(:,1),num(:,2))
end

カテゴリ

Help Center および File ExchangeTitle についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by