Matlab-Matrix Tutorial
Selected Reading
- Matlab Matrix - Discussion
- Matlab Matrix - Useful Resources
- Matlab Matrix - Quick Guide
- Matlab-Matrix - Deletion Row & Coloumn
- Matlab-Matrix - Transpose
- Matlab-Matrix - Rank
- Matlab-Matrix - Trace
- Matlab-Matrix - Inverse
- Matlab-Matrix - Matrix Determinant
- Matlab-Matrix - Subtraction
- Matlab-Matrix - Addition
- Matlab-Matrix - Multiplication
- Matlab-Matrix - Working with Matrices
- Matlab-Matrix - Create Matrix
- Matlab-Matrix - Environment Setup
- Matlab-Matrix - Introduction
- Matlab-Matrix - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Matlab-Matrix - Trace
Matlab-Matrix - Trace
Trace helps you to calculate the sum of diagonal elements in a given matrix.
Example
Consider the given 3x3 matrix. Let us find out the sum of diagonal elements as shown below −
a = [ 1 2 3; 2 3 4; 1 2 5]; test = trace(a)
Output
The execution in MATLAB is as follows −
>> a = [ 1 2 3; 2 3 4; 1 2 5] test = trace(a) a = 1 2 3 2 3 4 1 2 5 test = 9 >>Advertisements