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

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

댓글을 달려면 로그인하십시오.

답변 (2개)

Rik
Rik 2017년 2월 21일

1 개 추천

.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 2017년 2월 21일

0 개 추천

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

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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2017년 2월 21일

댓글:

2017년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by