Calculation Of Absolute Values Of Numbers, Vectors And Matrices In MatLab®(Illustrated Expression)

1 min reading time..

There are lots of kinds of mathematical functions in Matlab®. These mathematical functions can be very useful when they are used properly in Matlab® codes. In this article, we will explain how to calculate the absolute values of variables such as integers, vectors, and matrices in Matlab®.

How To Use ‘abs()’ Code To Calculate Absolute Values In Matlab®?

>> a = [2 6 3; 45 36 3; 4 5 6];
b = [2 5 9 3 9 5 3 9];
c = 45;
abs(a)
abs(b)
abs(c)

ans =

     2     6     3
    45    36     3
     4     5     6


ans =

     2     5     9     3     9     5     3     9


ans =

    45

>> 

We created variables as ‘a’, ‘b’, and ‘c’ that are respectively matrix, vector, and an integer as shown above in Matlab®. Also, we respectively calculated their absolute values by typing them inside the parenthesis of abs() command. As you understand that the ‘a’ matrix all element’s absolute values are calculated individually as shown above.

Also, this is valid for the absolute value calculation of vectors. The whole elements of the vector ‘b’ absolute values are calculated individually. Also, the sign value of ‘c’ is directly calculated as absolute with abs() command as shown in Matlab®.

Conclusion

So the logic is very basic.

Do not forget to leave your comments and questions below about the use of the abs() command in Matlab® below. 

If you want further coding examples about the abs() command in Matlab®, inform us in the comments.

This article is prepared for completely educative and informative purposes. Images used courtesy of Matlab®

Your precious feedbacks are very important to us.

COMMENTS
There are no comments for this article yet! You can make the first comment.
Leave a Comment

x