How fill a part of 3D array with decreasing values?

1 view (last 30 days)
Dear all,
I have a 3D array and I just want to fill a buck of this array with decreasing values, with step i've chosen. The values would decrease only in one direction, and constant on the two others.
For instance i have this : >> N=10; >> X=zeros(N,N,N); >> X(:,:,1:10)=20:-2:2; ??? Assignment has fewer non-singleton rhs dimensions than non-singleton subscripts
Could somebody help me with the syntax please?
Thanks in advance.
Alexandre.

Accepted Answer

Carlos
Carlos on 8 Mar 2013
I think you are trying to do something like this
>> a=20:-2:2;
>> for i=1:10
for j=1:10
X(i,j,1:10)=a(1:10);
end
end

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!