Next Post:

Creating Helical Patterns In Siemens NX(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;

ans =

     2     6     3
    45    36     3
     4     5     6

ans =

     2     5     9     3     9     5     3     9

ans =



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®.


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.

  • Site Comments

At least 10 characters required.