How can i store a .mat file into a variable?

조회 수: 2 (최근 30일)
sam  CP
sam CP 2017년 3월 21일
댓글: Stephen23 2020년 4월 22일
i want get the syntax to store a .mat file into a variable.

채택된 답변

Walter Roberson
Walter Roberson 2017년 3월 21일
fid = fopen('YourMatFile.mat', 'r') ;
YourVariable = fread(fid, '*uint8').' ;
fclose(fid) ;
YourVariable is now a row vector of bytes that make up the mat file.
This kind of thing can be useful if you need to transmit a mat file over wireless or Ethernet, but otherwise has limited use.
.... But perhaps the answer you were looking for was just
YourVariable = load('YourMatFile.mat');
  댓글 수: 4
Kieran Graham
Kieran Graham 2020년 4월 22일
Hi, I am also having a similar problem. I have 23 variables stored in my temp.mat file. Is it possible to use these values by simply using load('temp.mat', 'variable1', 'variable2', ....) or will I need to recover the values 1 by 1?
Thanks
Stephen23
Stephen23 2020년 4월 22일
@Kieran Graham: the recommended approach is to simply load into an output variable
S = load(...);
All of your variables will be fields in the scalar structure S, and are trivial to access.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Test and Measurement에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by