【问题标题】:How to convert .mat file into .txt file containing a matrix of 1088 rows and 832 columns?如何将 .mat 文件转换为包含 1088 行 832 列矩阵的 .txt 文件?
【发布时间】:2019-12-21 07:48:13
【问题描述】:

我想要一些关于我的 Matlab 问题的帮助。我正在使用 Matlab R2016b 开发 macOS。我想将包含 1088 行和 832 列的矩阵的 .mat 文件转换为 .txt 文件。

我尝试了上面的代码但没有成功。

load('H.mat')
dlmwrite('H.txt')

通过在 matlab 上加载矩阵,我发现以下信息:

谢谢。

【问题讨论】:

  • 需要指定要写入文件的矩阵:dlmwrite('H.txt', H)
  • 谢谢 Lui mendo,我试过你的代码,但我发现这个错误:Undefined function 'real' for input arguments of type 'struct'.Error in dlmwrite (line 189)str = sprintf('%.*g%+.*gi',precn,real(m(i,j)),precn,imag(m(i,j)));
  • 抱歉,我没有意识到 H 是一个名为 codestruct 变量的字段。试试dlmwrite('H.txt', code.H)

标签: matlab matrix


【解决方案1】:

dlmwrite 不是recommended by matlab: 更好用

load('H.mat')
writematrix(H, 'H.txt') 

请参阅writematrix 文档。

【讨论】:

  • 感谢 BitLaucher,我已经尝试过您的代码,但发现此错误:Undefined function or variable 'writematrix'.
  • writematrix 函数仅存在于最新的 Matlab 版本中
  • 我已经安装了matlab 2019,它可以工作了,谢谢。
猜你喜欢
  • 2017-11-03
  • 2015-06-11
  • 2020-10-17
  • 2012-07-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-21
相关资源
最近更新 更多