为了分析某些数据,我有几个脚本,它们使用相同的输入并计算不同的内容。我想让Matlab然后将每个脚本的输出写入相同的csv,以便将所有输出都放在一个位置。我该怎么做呢?甚至没有可能在Matlab中制作一个巨大的矩阵并将整个矩阵写成一个逗号吗?据我所知,writematrix仅写入第一列。
示例:
A = rand(1,10)'; B = rand(1,10)';
writematrix(A,'M.xls')%写入csv的第1列
writematrix(B,'M.xls')%这将覆盖先前的命令
您可以在xcel中写到不同的图纸,但这不合适。
writematrix的文档在这里:https://uk.mathworks.com/help/matlab/ref/writematrix.html
TIA
使用'Range'
属性指定第二列的范围(或起始单元格,并为'append'
使用WriteMode
,如下所示:
A = rand(10,1); B = rand(10,1);
%Side-note: ' is complex conjugate transpose.
%Use transpose .' when you want to take transpose
%In this case, you can initialise the random matrices with 10x1 size
%instead of 1x10 size and then taking the tranpose
writematrix(A,'M.xls');
%Assuming that B1 is the starting cell for the second column:
writematrix(B,'M.xls','Range','B1', 'WriteMode', 'append');