Assuming that a
and b
are vectors of the same size, you can define the matrix a
as the product between b
and a
using the matrix multiplication operator *
in Matlab as follows:
main.m11 chars2 lines
This will compute the product between the elements of vector b
and vector a
and store the resulting matrix in a
.
Note that the order of the multiplication matters, since matrix multiplication is not commutative. In this case, we're multiplying b
by a
, which means that the number of columns in b
must match the number of rows in a
.
Also, be careful when using the assignment operator =
to avoid overwriting existing variables unintentionally.
gistlibby LogSnag