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

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

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

Leave a Reply

Your email address will not be published. Required fields are marked *


Please

leave feedback ?

( For the post )

ASK THE MECHANICALLAND

COMMUNITY


We are always open to your feedback to improve ourselves and the quality of our content! If you have any suggestions, thoughts, or criticism, please let us know. We are trying to improve our blog with constructive feedback. We are aware of how valuable your feedback is for our future development, and we will carefully read all your comments. Thank you in advance!