Plotting reflectance against time
이전 댓글 표시
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%')
채택된 답변
추가 답변 (1개)
Geoff Hayes
2017년 4월 22일
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).
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!