MATLAB Answers

0

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

Asked by Veena Sanmugananthan on 13 Oct 2019
Latest activity Edited by Samatha Aleti on 16 Oct 2019
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

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Samatha Aleti on 16 Oct 2019
Edited by Samatha Aleti on 16 Oct 2019

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”:

  0 Comments

Sign in to comment.