Read data from Excel

2 views (last 30 days)
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;
Wavelength = xlsread('Calcite.xlsx','A6:A2156');
reflection = xlsread('Calcite.xlsx','B6:B2156');
lmin = islocalmin(reflection,"MinSeparation",150);
title('(111b Sample) Relative Reflectance--Wavelength')
ylabel('Relative Reflectance')
grid on
grid minor

Accepted Answer

Marcus Glover
Marcus Glover on 24 Jan 2022
Edited: Marcus Glover on 24 Jan 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
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
Marcus Glover
Marcus Glover on 25 Jan 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!

Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!