MATLAB: SUbstitions

MATLABsubstitutionsymbol to numbers

Hello,
I have a vector of 15 elemetnts which are functions of 4 elements, here below represented:
h(i)=[1, csi_1, csi_2, csi_3, csi_4, csi_1^2 - 1, csi_1*csi_2, csi_1*csi_3, csi_1*csi_4, csi_2^2 - 1, csi_2*csi_3, csi_2*csi_4, csi_3^2 - 1, csi_3*csi_4, csi_4^2 - 1]
I have 15 different vectors with the valus which those variables should have. E.g. s=[1 2 3 4] gives:
[1, 1, 2, 3, 4, 0, 2, 3, 4, 3, 6, 8, 8, 12, 15]
DO you have any suggestion how to impose for the 15 different cases the different values of csi_i in order to obtain a matrix of only coefficients.
At the moment the expression in csi_i are in the form h(1)=1, h(2)=csi_1, h(3)=csi_2 etc…
I tried with subs but I did not succeed.
THank you very much for your help and suggestions! ANtonio

Best Answer

M = @(csi) [1, csi(1), csi(2), csi(3), csi(4), csi(1)^2 - 1,...
csi(1)*csi(2), csi(1)*csi(3), csi(1)*csi(4),...
csi(2)^2 - 1, csi(2)*csi(3), csi(2)*csi(4),...
csi(3)^2 - 1, csi(3)*csi(4), csi(4)^2 - 1];
s=[1 2 3 4];
M(s) % You can use this directly or assign the results to an array.
%
%
%
% EDIT
If you want to be able to do it all at once for n-by-4, then:
M = @(csi) [ones(size(csi,1),1), csi(:,1), csi(:,2), csi(:,3), csi(:,4),...
csi(:,1).^2 - 1,csi(:,1).*csi(:,2), csi(:,1).*csi(:,3),...
csi(:,1).*csi(:,4), csi(:,2).^2 - 1, csi(:,2).*csi(:,3),...
csi(:,2).*csi(:,4), csi(:,3).^2 - 1, csi(:,3).*csi(:,4),...
csi(:,4).^2 - 1];
s = rand(15,4);
M(s)