image processing - How to assign a value to multiple cells in a n-dimensional array in Octave -
suppose have 3x3x3 3d-array called , 3x3 matrix called b, created following:
a = zeros(3,3,3); b = magic(3);
my intention turn elements @ 2nd , 3rd positions of a's 3rd dimension matrix b, like
a(:,:,1) = a(:,:,2) = a(:,:,3) = 0 0 0 8 1 6 8 1 6 0 0 0 3 5 7 3 5 7 0 0 0 4 9 2 4 9 2
my first try make
a(:,:,2:3) = b
but following:
error: a(i,j,...) = x: dimensions mismatch
it feels strange me, since, instance,
b(1,1:2) = 10
would produce correct result.
how solve this?
thanks in advance
forget it, solved following:
a(:,:,1:2) = repmat(b, [1 1 2])
:)
Comments
Post a Comment