Read data from Excel

8 ビュー (過去 30 日間)
Anton Vernytsky
Anton Vernytsky 2022 年 1 月 24 日
コメント済み: Marcus Glover 2022 年 1 月 25 日
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

採用された回答

Marcus Glover
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 件のコメント
Anton Vernytsky
Anton Vernytsky 2022 年 1 月 25 日
Thank you,it works ! Funny but my i7 and 8GB RAM cant run 95 figuers and one. I will do it 20 plots each time.
Marcus Glover
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 ExchangeSpreadsheets についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by