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 comentarios

KSSV
KSSV el 21 de Feb. de 2017
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

Iniciar sesión para comentar.

Respuestas (2)

Rik
Rik el 21 de Feb. de 2017
.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 el 21 de Feb. de 2017
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 comentario

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.

Iniciar sesión para comentar.

Categorías

Etiquetas

Aún no se han introducido etiquetas.

Preguntada:

el 21 de Feb. de 2017

Comentada:

el 21 de Feb. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by