I'm new in MATLAB and I have the following formula for the following problem. If I want to set a grey scale from 64 to 256, I just modify a matrix to create a M[256,3] where:
- M[Xi,1]=M[Xi,2]=M[xi,3]
- M[Xi,Yi] < M[Xi+1,Yi]
- M[1,Yi]=0
- M[256,Yi]=1.
So I need to create a matrix with steps that I don't know; the last element is 1 and the first is 0, I got the following formula that works with any column:
C[i]= X0 - (Xn*i -Xn)/N
where X0=0, Xn=1 and N=256.
with a loop like this:
k=(1:256);
for i=1:256,
   k(i)=(i-1)/255;
and then setting the values to the palette of colors
palette=zeros(256,3);
 for ii=1:3, 
     palette(:,ii)=k;
 end
Is there any other alternative to do is? It is really annoying using that much loops for something I think MATLAB must have: seting the values to an array based on the first element, the last element and the size of the vector.
 
     
     
     
    