Next Post:

Multiple Selection Types In AutoCAD Drawing Scheme(Illustrated Expression)

Saving Matrices In MatLab® To Computer(Illustrated Expression)

Sometimes you need to save matrices in Matlab®. For example, you created a matrix according to data that you are collecting in Matlab®, what you need to do is save the data that you collected as a matrix file. You can load this saved matrix whenever you want into Matlab®. The extension of the matrix is .mat. In this article, we will show you how to save matrices created in Matlab®.

YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!

How To Save And Load A Matrix In Matlab®?

>> A(1,1)=1;
A(1,2)=3;
A(1,3)=5;
A(2,1)=7;
A(2,2)=8;
A(2,3)=11;
A(3,1)=100;
A(3,2)=1;
A(3,3)=4

A =

     1     3     5
     7     8    11
   100     1     4

>> 

For example, we want to save the created matrix above as “Factors” to the D: directory. Type “save D:\Factors” then press enter. This matrix will be saved to the D: directory with the name of “Factors”.

>> A(1,1)=1;
A(1,2)=3;
A(1,3)=5;
A(2,1)=7;
A(2,2)=8;
A(2,3)=11;
A(3,1)=100;
A(3,2)=1;
A(3,3)=4

A =

     1     3     5
     7     8    11
   100     1     4

>> save D:/Factors

We wrote the save command for this matrix in Matlab® then we pressed Enter.

Saved matrix file in Matlab®.

The Factors matrix file is saved as shown by the red arrow above. You can open this by typing “load D:\Factors” then press enter to load it in Matlab®.

Loaded matrix that saved before in Matlab®.

As you can see, we typed “load D:\Factors” to the command window in Matlab®, then the related matrix is opened at Workspace that is shown by the red arrow above.

Conclusion

The saving and loading of a matrix in Matlab® are simple like that.

Do not forget to leave your comments and questions below about the saving and loading of a matrix in Matlab® below. 

If you want further coding examples about saving and loading of a matrix 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.