How do I import an old .mat code, open the script and run it?

How do I import an old .mat code, open the script and run it? I am only able to import the variables but not the complete code!

2 Kommentare

That case you have to specify the errors.
The below is what I get when I tick off: ''Generate MATLAB code'' but what does this mean? I can see all the variables and constants but not the actual code...
function importfile(fileToRead1) %IMPORTFILE(FILETOREAD1) % Imports data from the specified file % FILETOREAD1: file to read
% Auto-generated by MATLAB on 21-Feb-2017 11:46:10
% Import the file newData1 = load('-mat', fileToRead1);
% Create new variables in the base workspace from those fields. vars = fieldnames(newData1); for i = 1:length(vars) assignin('base', vars{i}, newData1.(vars{i})); end

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Rik
Rik am 21 Feb. 2017

1 Stimme

.mat files do not contain code AFAIK, so unless you saved code into something like an anonymous function, you cannot load code by loading a .mat file. You should look for .m files if you want code.
Jan Oredsson
Jan Oredsson am 21 Feb. 2017

0 Stimmen

Okey, I think I understand but please confirm: if I only can find .mat-files, then this means I have actually lost these codes and I can never retrieve them again!?

1 Kommentar

Likely, but not definite. You might happen to have saved anonymous functions in the .mat . In the case of graphics objects, sometimes code is attached to the graphics objects -- though usually any substantial code would be in .m files instead of in graphics objects.

Melden Sie sich an, um zu kommentieren.

Kategorien

Tags

Noch keine Tags eingegeben.

Gefragt:

am 21 Feb. 2017

Kommentiert:

am 21 Feb. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by