MATLAB: Use matrix, premutation

mnatlab

i use the command
c=[1,2,3,4,5] perms(c)
to generate all permutation of c. and there are 2 equation which use the
j=sin(0*c)+sin(72*c)+sin(144*c)+sin(216*c)+sin(288*c)
k=cos(0*c)+cos(72*c)+cos(144*c)+cos(216*c)+cos(288*c)
and Z=j+k
how can i find what permutation for minimum z? the permutation must be the same for both j and k at the same time ie
j=sin(0*1)+sin(72*2)+sin(144*3)+sin(216*4)+sin(288*5)
k=cos(0*1)+cos(72*2)+cos(144*3)+cos(216*4)+cos(288*5)
i actually wrote the euqation wrong, sorry. but if
j=sin(0)*c+sin(72)*c+sin(144)*c+sin(216)*c+sin(288)*c
k=cos(0)*c+cos(72)*c+cos(144)*c+cos(216)*c+cos(288)*c
would that change anything?

Best Answer

Another way:
c=[1,2,3,4,5];
c=perms(c);
z=[];
j=[];
k=[];
for i=1:length(c)
j(i)=sin(0*c(i,1))*sin(72*c(i,2))+sin(144*c(i,3))+sin(216*c(i,4))+sin(288*c(i,5));
k(i)=cos(0*c(i,1))*cos(72*c(i,2))+cos(144*c(i,3))+cos(216*c(i,4))+cos(288*c(i,5));
z(i)=j(i)+k(i);
end
[p,q,r]=find(z==min(z));
c(q,:)
minz=min(z)