Extracting 2 coloumns from diifferent excel files, and trying to plot them

2 ビュー (過去 30 日間)
Veena Sanmugananthan
Veena Sanmugananthan 2019 年 10 月 13 日
編集済み: Samatha Aleti 2019 年 10 月 16 日
Hi all,
I'm trying to take 2 coloumns from a bunch of different excel sheets in my directory (all of them have same variables, just different values in each coloumn).
I want to plot the 2 coloumns and create individual plots for each sheet.
I have a code here that allows me to extract the two coloumns and plot it on the same plot, but it doesn't seem to be working.
Would someone be able to help me figure out why this isn't working? and what i can do to modify it so I can plot single plots for every excel sheet.
Code:
files = dir('*/*.xls');
for i=1:length(files)
data = xlsxread(files(i).name);
x=data(:,2);
y=data(:,3);
plot(x,y)
end

回答 (1 件)

Samatha Aleti
Samatha Aleti 2019 年 10 月 16 日
編集済み: Samatha Aleti 2019 年 10 月 16 日
As per my understanding you want to plot data of each excel sheet separately. You can use ”figure()” in the "for" loop to do this. Here is the sample code:
for i = 1:2
data = xlsxread(files(i).name);
x = data(:,1);
y = data(:,2);
figure(); % new figure window
plot(x,y);
end
Refer the following link for more details on “figure”:

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by