Following this, i've plotted a matrix of signals t
(m by 1) and x
(m by n):
plot(t,x);
and, after that, i am wishing to apply a coloured scheme on colormap matrix c
(n by 3). How to do it?
EDIT
Trivially, and ignoring most -if not all- performance etiquette, through a for
call you can set colours while building a plot, plotting each column inside the loop, and setting/applying the colormap 'on the fly', just as suggested by the pointed post, but which is not the question:
for i=1:n
plot(t(:,1),x(:,i),'Color',c(i,:));
hold on;
end
This is pseudocode which will not run if you don't have t
, x
and c
defined.
Data, and the code shown here, cooked, just ready for you:
load spectra.mat;
x=NIR'; m=size(x,1);n=size(x,2);
t=900+2*(1:m)'; %Don't question this :)...
c=winter(n);
for i=1:n
plot(t(:,1),x(:,i),'Color',c(i,:));
hold on;
end
title('Near Infrarred Spectra for Gasoline Samples');
xlabel('Wavelength [nm]');
ylabel('Infrarred Spectral Magnitude [lm^2/nm]');
or without the for
, better:
load spectra.mat;
x=NIR'; m=size(x,1);n=size(x,2);
t=900+2*(1:m)'; %Don't question this :)...
c=winter(n);
set(0,'DefaultAxesColorOrder',c);
plot(t,x);
title('Near Infrarred Spectra for Gasoline Samples');
xlabel('Wavelength [nm]');
ylabel('Infrarred Spectral Magnitude [lm^2/nm]');
.
All them unfortunately prior the plotting. Never after...