3 ms·
"""If you want to multiply scalars or otherwise do element-wise operations, you have to prefix the '*' operator with a '.'. """ what???
by GFK_of_xmaspast 13y ago
"""If you want to multiply scalars or otherwise do element-wise operations, you have to prefix the '*' operator with a '.'. """
what???
- quux 13y agoYou don't have to use .* and friends when operating in 2 scalers, 2 * 3 works just fine. But if you have 2 matrices A and B, A * B does a matrix multiplication, And A .* B is needed for element wise multiplication. I'm still new to matlab, but the place where this has bitten me is if I'm trying to write code that works on either a scalar or vector of scAlars, if you aren't specific, the code my run fine against a single scalar, but blow up or do the wrong thing with a vector.