Addition Of Diagonal Elements Of A Matrix In MatLab(Illustrated Expression)

In this article we will show another linear algebra command of Matlab that adds the diagonal elements of a matrix. You know already that Matlab has lots of special commands about linear algebra that Mechanical Base includes all of them as article like this.

Also you can find lots of contents about Matlab like this article in Mechanical Base to learn Matlab completely. Visit the main page of Mechanical Base!

How To Add Diagonal Elements Of A Matrix In MatLab?

Usage of trace() command in Matlab.

To add the diagonal values of matrix ‘a’, we need to use trace(a) command to do it in Matlab.

For example ‘b’ is the diagonal addition value of matrix ‘a’ that obtained with trace() command as shown by red arrow above in Matlab.

‘c’ is the multiplication of diagonal addition value of matrix ‘a’ with 5 that shows it it possible to make mathematical calculations with diagonal addition values of matrices as shown by green arrow in Matlab.

‘d’ is the exponentiated value of diagonal summation of matrix ‘a’ with 3 that also shows all of the mathematical calculations are valid for trace() command in Matlab.

So it is very easy to take the diagonal summations of matrices in Matlab with trace() command.

Share This Post! Share Tweet Share

Write your comment on this topic.