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

3 visualizaciones (últimos 30 días)
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

Respuestas (1)

Samatha Aleti
Samatha Aleti el 16 de Oct. de 2019
Editada: Samatha Aleti el 16 de Oct. de 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”:

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by