MATLAB数据处理
将常用的matlab处理方法记录如下,
官方的帮助网站: https://ww2.mathworks.cn/help/
将数据写入文本
xlswrite(filename,A) 将矩阵 A 写入 Microsoft Excel电子表格工作簿 filename 中的第一个工作表,从单元格 A1 开始写入。
例如,xlswrite('./dist_in 1.xlsx',dist_in(:,:,1)); //这里dist_in为三位数组,目的是将前两维数据写入对应的xlsx文件中.
仿真过程中会报如下错误:
Warning:Could not start Excel server for export. XLSWRITE will attempt to write file in CSV format.
不用管它,实际会产生对应名称的.csv文件.
其他相关用法可参考 https://ww2.mathworks.cn/help/matlab/ref/xlswrite.html
从文本读取数据
M = csvread(filename) 将逗号分隔值 (CSV) 格式化文件读入数组 M 中。该文件只能包含数值。
其他相关用法可参考 https://ww2.mathworks.cn/help/matlab/ref/csvread.html
打印信息
格式化打印用fprintf('data = %f\n',data);
数组打印用disp(M); disp也可以直接打印字符串,比如disp('debug info');
matlab中用单引号''

浙公网安备 33010602011771号