square of a vector
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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??
0 Kommentare
Akzeptierte Antwort
Honglei Chen
am 31 Okt. 2012
Bearbeitet: Honglei Chen
am 31 Okt. 2012
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)
6 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!