Read data from Excel
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Anton Vernytsky
el 24 de En. de 2022
Comentada: Marcus Glover
el 25 de En. de 2022
Hello,want to plot data from excel,I wrote a code and its works but its only for the first column and i have 98 of them.
My question i can use "for" loop for example to make me all the 98 plots,i will write here my code and the plot example.
The wavelength need to stay the same range but i need that the reflection will go to C,D,E,F.... columns.
Thank you for your help.
clear all;
clc;
Wavelength = xlsread('Calcite.xlsx','A6:A2156');
reflection = xlsread('Calcite.xlsx','B6:B2156');
lmin = islocalmin(reflection,"MinSeparation",150);
figure;
plot(Wavelength,reflection,Wavelength(lmin),reflection(lmin),'ro')
title('(111b Sample) Relative Reflectance--Wavelength')
xlabel('Wavelength[nm]')
ylabel('Relative Reflectance')
grid on
grid minor
0 comentarios
Respuesta aceptada
Marcus Glover
el 24 de En. de 2022
Editada: Marcus Glover
el 24 de En. de 2022
Yes, you can do this, but you will need to read in the entire excel file (or at least the entire dataset) first. Then just define what you need. You are only reading in one reflection column (B) of your excel sheet.
xlsdata=xlsread('Calcite.xlsx'); %reads entire file
Wavelength=xlsdata(6:2156,1);
for i=1:98 %or however many columns you need
reflection=xlsdata(6:2156,i+1); %starts with 2nd column, will go to number 99
figure(i)%to generate a new figure each time- this will make 98 plots
%do your plotting
end
3 comentarios
Marcus Glover
el 25 de En. de 2022
Yeah, I was going to say it may not be a good idea to make 98 figures at once- not sure exactly why but figures are resource intensive and really slow things down. I usually suppress them and save them automatically then open them individually if I actually need to. No matter how you slice it, 98 fiugures is a lot!
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!