Matlab CSV data and if statement
1 view (last 30 days)
Show older comments
Onur Hakverdi
on 19 Jun 2021
Commented: Onur Hakverdi
on 19 Jun 2021
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 Comments
Accepted Answer
Walter Roberson
on 19 Jun 2021
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'))
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!