0
votes

I start from a matrix of the shape: N · 2 · M which I call it as x. Then, I have another matrix called theta of the shape M. The following code give me the following error in octave: nonconformant arguments (op1 is 2x2x2, op2 is 2x2x2).

  x(n+1,:,:) = x(n+1,:,:) + [cos(theta(:)) sin(theta(:))]

what is wrong with it?

PS. Here is the complete code:

M=30;
N=32;

for n=1:1:N
    z = [1.0 0.0]
    x(1,1,1:M) = z(1);
    x(1,2,1:M) = z(2);

    x(n+1,:,:) = x(n,:,:) + randn([1,2,M])
    theta(:) = randn([M,1]);
    x(n+1,:,:) = x(n+1,:,:) + [cos(theta(:)) sin(theta(:))]
end
1

1 Answers

3
votes

size([cos(theta(:)) sin(theta(:))]) is 30x2 while size(x(n+1,:,:)) is 1x2x30

They don't match.

I do not know if this is mathematically what you need (i.e. if the indices that get added together are the ones that should), but you can fix this by doing:

 x(n+1,:,:) = x(n+1,:,:) + reshape([cos(theta(:)) sin(theta(:))].',1,2,M);