Matlab CSV data and if statement
2 次查看(过去 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.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/658435/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/658435/image.jpeg)
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!