Something like that:
lam1 = 0:0.1:4; %lam1 now has 41 elements 0, 0.1, 0.2, ..., 4.0
lam = lam1; % just to create another array of the same size, could use zeros()
lam = 1.6*lam1-0.30*lam1.^2;
% note, operating on all elements in both arrays, will overwrite wrong entries in lam next; more elegant (perhaps quicker too) would be to only operate on lam(1:11)
lam(12:end) = lam1(12:end)+0.3;
but if you have a bunch, the Matlab path must write a function to execute them.
Oh, and you have lam1==1in both conditions, you have to fix it.
EDIT: for extra astringency you can write:
lam = 1.6*(0:0.1:4)-0.3*(0:0.1:4).^2;
lam(12:end) = (1.1:0.1:4)+0.3;
In this version, I left 1 in the first part, the second part starts with 1.1
source
share