【问题标题】:MATLAB won't open a file created by OctaveMATLAB 不会打开 Octave 创建的文件
【发布时间】:2017-04-06 23:18:25
【问题描述】:

我使用 Octave 生成​​并保存了大量数据文件,现在我需要在 MATLAB 中打开它们作为分析它们的一部分。 MATLAB 吐出这个错误。

Error using load
Unable to read MAT-file
[file path]/PhPar_40.mat: not a binary MAT-file.
Try LOAD -ASCII to read as text.

尝试它的 load -ASCII 建议然后给出这个错误。

Error using load
Number of columns on line 2 of ASCII file
[filepath]/PhPar_40.mat must be the same as previous lines.

我(现在)知道 Octave 能够以 MATLAB 可读格式保存,但重新创建这些数据文件会花费大量时间,而且确实不是一种选择。有没有办法让 MATLAB 读取这些文件?

【问题讨论】:

  • 请分享您用于将文件保存为八度的命令。

标签: matlab octave compatibility


【解决方案1】:

MATLAB 无法打开这些文件,因为这些文件没有按 octave 正确保存。尝试通过以下命令将它们保存为八度:

save -mat7-binary '[filepath]/PhPar_40.mat' 'm'

如果您有大量文件,您可以将所有文件放在文件夹中,然后运行迭代器以自动读取所有加载并以正确格式保存。这个迭代器看起来像:

file = dir('[filepath_read]/*.mat'); 
index = 1;   
while (index==length(file)+1)
   m = load('file(index).name')
   save -mat7-binary strcat("[filepath_write]/", file(index).name, ".mat") 'm';
   index = index+1;
   pause(1);
endwhile

将所有文件转换为正确格式后,将它们加载到 MATLAB 中。希望能解决你的问题

【讨论】:

  • 为什么你认为“这些没有正确地按八度保存。”?你知道 eyeballfrog 用来保存文件的参数吗?
猜你喜欢
  • 1970-01-01
  • 2016-02-15
  • 2011-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-06
  • 2018-07-27
相关资源
最近更新 更多