consider the two matrices a = [ 8 7 11; 6 5 -1; 0 2 -8] b = [ 2 1 2; -1 6 4; 2 2 2;] and compute in their array product and matrix product in matlab

To compute the array-product of two matrices a and b means to multiply each corresponding element in a with the corresponding element in b. In MATLAB, we can perform array multiplication using element-wise multiplication with the .* operator.

To compute the matrix-product of two matrices a and b means to multiply the rows of a with the columns of b. In MATLAB, we can perform matrix multiplication using the * operator.

Here is the code to compute the array-product and matrix-product of the given matrices in MATLAB:

main.m
a = [8 7 11; 6 5 -1; 0 2 -8];
b = [2 1 2; -1 6 4; 2 2 2];

% Compute the array-product of a and b
array_product = a .* b

% Compute the matrix-product of a and b
matrix_product = a * b
185 chars
9 lines

Output:

main.m
array_product =

    16     7    22
    -6    30    -4
     0     4   -16


matrix_product =

    61   104   100
     7    13    28
    -4    -4    -4
151 chars
13 lines

gistlibby LogSnag