Internet User
Internet User

Reputation: 39

why Is blkdiag showing error?

This is the code that I wrote to my octave console:

disp("Hello World"); 

n=4; 

B=[1,1,1,1;2,2,2,2;3,3,3,3;4,4,4,4];

R=eye(7); 

for i=1:n 

   gamma(i)=blkdiag(eye(n-i),B,eye(i-1))

end; 

gamma(i)

But, I am getting this error:

error: my_script.my: A(I) = X: X must have the same size as I

Any help. Thanks beforehand.

Upvotes: 1

Views: 55

Answers (1)

Internet User
Internet User

Reputation: 39

As pointed out by beaker, to index the matrices, we need to use another indexing element. Therefore, the right syntax to get the syntax obviated is:

gamma(:,:,i)

instead of

gamma(i)

Upvotes: 1

Related Questions