Reputation: 6668
In MATLAB I have two vectors which are both 1 x 310 of type doubles.
So I have a line shown below. ret & bret are my vectors. This result produces another vector act_r of 1 X 310 of type double - all makes sense.
act_r = (ret - bret);
However when I try to divide every element in ret by its corresponding element in bret (again shown below) I get a single number. Why is this? How do I get Matlab to divide every element in ret by the corresponding element in bret?
act_d = (ret / bret);
Upvotes: 0
Views: 52
Reputation: 1390
MATLAB (the name comes from MATrix LABoratory) per default excutes matrix operation so ret/bret
will be evaluated as a matrix operation:
x = B/A
uses the mrdivide
operator (a overload of /
) which solves systems of linear equations xA = B for x hence returning a scalar.
while x =A./B
uses the rdivide
operator which divides each element of A by the corresponding element of B
more information here
Upvotes: 1