Matlab save .mat file as .txt file

%把矩阵 matrix 保存成任意后缀的文件
%转换成 .txt 举例:mat2txt( 'filename.txt', data );
%转换成 .corr 举例:mat2txt( 'filename.corr',data );

function back = mat2txt( file_Name, matrix ) 
fop = fopen( file_Name, 'wt' );
[M,N] = size(matrix);
for m = 1:M
    for n = 1:N
        fprintf( fop, ' %s', mat2str( matrix(m,n) ) );
    end
    fprintf(fop, '\n' );
end
back = fclose( fop ) ;

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324036868&siteId=291194637