matrix - Matlab - plot and color samples based on data -


i have following data:

  • datamatrix (20x210): 20 samples 210 variables each
  • wavelength: 1 row of 210 variables describing wavelength number
  • concentrations: concentration value each sample (20 rows , 1 column)

i plot data in normal way:

plot(wavelength, datamatrix) 

but want plot , color each sample according concentration value taking account rest, color based on data. think colormap. result this:

is there easy way using matlab?

thank much!

plot accepts line property including line color,

plot(wavelength, datamatrix, 'color', [0,0,0.1]) 

colormap can convert built-in color maps rgb matrices,

nlines = length(concentrations); cmap = hsv(nlines) 

mapping concentration color easy sorting numbers

c = concentrations - min(concentrations); c = ceil( c/max(c)*nlines ); 

finally, draw each line separately

for ii = 1:nlines     plot(wavelength, datamatrix(ii,:), 'color', cmap(c(ii),:))     hold on end hold off 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -