How to store a matrix obtained in a particular file/directory??

Good morning.. In fact, say I am running a program which generates a parity-check matrix of size 1000X2000... I would like to know how to save that parity check matrix for later use without having to run the program each time since it takes a lot of time...

 Réponse acceptée

Data = rand(1000, 2000) > 0.3; % Testdata
save(fullfile(tempdir, 'myParityCheck.mat'), 'Data', '-mat');
And reload the values:
FileData = load(fullfile(tempdir, 'myParityCheck.mat'));
Data = FileData.Data;

2 commentaires

Thanks.. It worked..
But where has it been saved actually?
Is there any restriction for the file name?
Like I would like to save it under 1000X2000matrix...
It is saved in tempdir, which replies your TEMP folder. Just type "tempdir" in the command window to find the location.

Connectez-vous pour commenter.

Plus de réponses (1)

save command stores variable in a MATLAB formatted binary file (MAT-file):
save(filename, 'your_matrix')
To load data from MAT-file into workspace use load function:
load(filename)

2 commentaires

I have tried as you mentionned for a 12X16 matrix for the time being..
save(12X16H_matrix, 'H1.mat')
I am getting an error saying unexpected matlab expression..
Is there anything I missed out ?
Is 12X16H_matrix your file name and H1 matrix name?
If so, then:
save('12X16H_matrix', 'H1')

Connectez-vous pour commenter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by