Plotting reflectance against time
Mostrar comentarios más antiguos
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%')
Respuesta aceptada
Más respuestas (1)
Geoff Hayes
el 22 de Abr. de 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 comentario
Adam Woolsey
el 22 de Abr. de 2017
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!