If you have two matrices in MATLAB with different dimensions and you want to make them the same size, you can use the zeros()
function to create a matrix of the desired size and then copy the values from the original matrices into the new matrices.
main.m335 chars19 lines
In the above code, we create a matrix of zeros C
with the same size as matrix A
using the size()
function. We then use indexing to copy the values of A
into C
. Similarly, we create a matrix of zeros D
with the same size as matrix B
and then copy the values of B
into D
. After these operations, C
and D
will be the same size.
gistlibby LogSnag