To find the difference between two vectors in each value in Matlab, you can use the following code:
main.m74 chars4 lines
In this example, we have two vectors vector1
and vector2
. The difference
variable will contain the element-wise difference of the two input vectors.
Alternatively, you can use the minus
function to achieve the same result:
main.m38 chars2 lines
Either way, the resulting difference
variable will be:
main.m34 chars4 lines
This indicates that the difference between the first elements of vector1
and vector2
is 3
, the difference between the second elements is 3
, and the difference between the third elements is 3
.
gistlibby LogSnag