Borrar filtros
Borrar filtros

Matlab CSV data and if statement

1 visualización (últimos 30 días)
Onur Hakverdi
Onur Hakverdi el 19 de Jun. de 2021
Comentada: Onur Hakverdi el 19 de Jun. de 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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 19 de Jun. de 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'))

Más respuestas (0)

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by