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

조회 수: 5 (최근 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 CenterFile Exchange에서 Display and Exploration에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by