absolute value of a vector

11 vues (au cours des 30 derniers jours)
Kyle
Kyle le 12 Fév 2014
Commenté : Roger Stafford le 12 Fév 2014
how can i determine the absolute value of a vector?
so for example
if i had x=[ -0.5 .3 .5 -0.5]
how would i determine the absolute value of each individual term in the vector?
i've tried using "abs" but it spits back one value.

Réponse acceptée

Roger Stafford
Roger Stafford le 12 Fév 2014
That isn't true of matlab's 'abs' function. For every value in x it will return its absolute value. For every individual complex number it will return the square root of the sum of the squares of its real and imaginary parts.
I suspect you have a false 'abs' function somewhere on your system that is being called instead of the true 'abs'. You had better check on that.
  5 commentaires
Kyle
Kyle le 12 Fév 2014
thank you!
Roger Stafford
Roger Stafford le 12 Fév 2014
I'll expand Matt's answer. You have used matrix division in yexact-y)/yexact and for this case the result would be a single 1 x 1 value, not a vector.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by