How to store a matrix permanently through matlab?

219 views Asked by At

In matlab I am getting a matrix of MxN size, I need to store this in secondary storage for retrieval in future. How I can store a matrix permanently and how it's possible to read into a variable.

1

There are 1 answers

0
Vidhya G On

Say your matrix is m. Save it to a file:

save myfile.mat m

You can save it as ascii:

save('myfile.txt','m','-ascii')

or as save -ascii myfile.txt m.

You can see the contents of this file:

type('myfile.txt')

You can load all the contents of your mat file:

load myfile.mat

or a specific variable:

load('myfile.mat','m')

or simply load myfile.mat m. Similarly load your data from the ascii file:

load myfile.txt -ascii

Once you have loaded the data from the mator ascii files you have the matrix m and you can set it equal to any variable that you like.