Matlab Matrix

  • Matrix A, B. What’s A(B)?

1. Elements of B are logical.

A =[1 2; 3 4]

1 2

3 4

B = [1 0; 1 0]

1 0

1 0

A(B) =

1 0

3 0

2. Elements of B are positive integers.

B = [1 1;2 2]

A(B) =

1 1

3 3

  • Matrix A is x dimension A(:,:,:…), how to copy A to matrix B(n,:,:,:,…)’s first dimension B(1,:,:,:…)?

d = size(A);

B = zeros([n size(A)]);

B( 1, : ) = A( : );

Advertisements