Asked by Berbia
on 31 Oct 2012

I have to calculate a square of vector which should results a scalar value. i.e) A=(B-C)^2 B and C are vectors and I need A as a scalar. How can I implement this in matlab??

*No products are associated with this question.*

Answer by Honglei Chen
on 31 Oct 2012

Edited by Honglei Chen
on 31 Oct 2012

Accepted answer

My guess is you need an inner product, i.e. A = `|B-C|`^2, you can do it many different ways, one way is

B = ones(3,1); C = ones(3,1); A = (B-C)'*(B-C)

Opportunities for recent engineering grads.

## 0 Comments