Is there a way to get rid of this warning? I know I can do "dot(expr, expr)" instead, but then I have to type the expression twice.Warning, ^ is ambiguous on non square matrices. Use .^ to apply ^ element by element.
vector^2 without a warning?
Modérateur : xcasadmin
vector^2 without a warning?
I often need to "dot product" a vector with itself. E.g., "(pointB - pointA)^2". But when I do this I see the warning:
Re: vector^2 without a warning?
Just follow the hint: replace ^ by .^ like (pointB - pointA).^2
Re: vector^2 without a warning?
Given the vector [a,b,c], I want to arrive at a^2 + b^2 + c^2.
[a,b,c]^2 does this (but gives a warning).
[a,b,c].^2 gives [a^2, b^2, c^2]. Not good.
I know I can do "[a,b,c]*[a,b,c]" or "sum([a,b,c].^2)", but I was wondering if there's a shorter syntax.
Re: vector^2 without a warning?
Indeed, sorry. l2norm(v)^2 will do.