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

1 回表示 (過去 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 Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by