Read data from Excel
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Marcus Glover
2022-1-24
编辑:Marcus Glover
2022-1-24
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 个评论
Marcus Glover
2022-1-25
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!
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!