如何将mat文件转换为xlsx文件

执行代码后,我收到一个错误:

load('firstdiff.mat') xlswrite('test.xlsx', firstdiff) 

mat文件只包含数字值( 01

未定义的函数或variables'firstdiff'

使用没有输出参数的load是经常混淆程序员的东西。 我build议使用它与输出参数:

 data=load('firstdiff.mat') 

这样你会得到一个包含你的mat文件数据的结构。 典型的下一步是使用fieldnames(data)来检查哪些variables存在,或者如果你已经知道,用一个像data.x这样的expression式索引一个variables

在这种情况下,我假设你的matfile只有一个variables。

 data=load('firstdiff.mat'); fn=fieldnames(data); %get all variable names assert(numel(fn)==1); %assert there is only one variable in your mat, otherwise raise error firstdiff=data.(fn{1}); %get the first variable xlswrite('test.xlsx', firstdiff); %write it