Plotting reflectance against time
Afficher commentaires plus anciens
I have plotted reflectance against wavelength using the following code, but now wish to plot reflectance against time. I have 2400 files each containing a complete spectrum at a certain point in time. There is 0.5 secs between each spectrum being recorded. I wish for the reflectance (2nd column) to be averaged for each spectrum
dirname='E:\Blue Wool Reflectance\';
head=[dirname 'BW Reflectance00000' '.txt'];
A=load(head);
wv=A(:,1);
R0=A(:,2);
mean(R0(200:1400))
timedifference=0.5
R=zeros(2048,2400);
for i=1:9
head=[dirname 'BW Reflectance0000' num2str(i) '.txt'];
A=load(head);
R(:,i)=A(:,2);
end
for i=10:99
head=[dirname 'BW Reflectance000' num2str(i) '.txt'];
A=load(head);
R(:,i)=A(:,2);
end
for i=100:999
head=[dirname 'BW Reflectance00' num2str(i) '.txt'];
A=load(head);
R(:,i)=A(:,2);
end
for i=1000:2400
head=[dirname 'BW Reflectance0' num2str(i) '.txt'];
A=load(head);
R(:,i)=A(:,2);
end
i=200;
figure(1)
plot(wv,R(:,i),'r')
xlim([400 700])
xlabel('\lambda')
ylabel('Reflectance%')
Réponse acceptée
Plus de réponses (1)
Geoff Hayes
le 22 Avr 2017
Adam - in the future, please format your code so that it is readable. I have done this for you, but all you need to do is to highlight the code and press the {}Code button.
So presumably your above code shows that every column of R is the reflectance for a particular spectrum. To calculate the average, use mean as
avgR = mean(R);
which you can then plot against time (which I don't think is the wv wavelength from above).
1 commentaire
Adam Woolsey
le 22 Avr 2017
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!