Extracting 2 coloumns from diifferent excel files, and trying to plot them
1 view (last 30 days)
Show older comments
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
Answers (1)
Samatha Aleti
on 16 Oct 2019
Edited: 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
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!