Matlab CSV data and if statement
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, I have a csv file data and it plots the wavelength-intensity relationship also it labels the highest peak point on the figure. So my question is this i have to make comparison using if statement but issue is that i need to change plot title according to intensity value. Let us say we have 209 and 200 intensities. if the highest intensity value is 209 than the title will be Cu-I elseif the highest intensity value is 200 than the title will be Al-I. I tried something like this but It doesn't plot.
댓글 수: 0
채택된 답변
Walter Roberson
2021년 6월 19일
Use discretize() to classify the data according to ranges of values. Then you can use the returned range number to index a list of chemicals.
Or remember that chances are almost none that your data will be bit for bit identical to 209.4549 and so you should not be using ==
if 209 < intensity_max && intensity_max < 210
title('CU-I')
elseif 199.5 < intensity_max && intensity_max < 200.5
title('Al-I')
else
title('Unknown species');
end
Also, we recommend that you do not use cd() much in code. Learn to use fullfile() instead. For example,
plotdir = 'C:\Plots';
saveas(gcf, fullfile(plotdir, 'plot.jpg'))
추가 답변 (0개)
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!