To analyse some data I have severral scripts that take the same input and calculate different things. I would like to have matlab then write the output of each script to the same csv so I have all the outputs in one place. How do I do this? Is this even possible w/o making a huge matrix in Matlab and writing the whole matrix in one comaand? As far as I can tell writematrix only ever writes to the first column.
Example:
A = rand(1,10)'; B = rand(1,10)';
writematrix(A,'M.xls') %write to column 1 of csv
writematrix(B,'M.xls') %this overwrites the previous command
You can write to different sheets in xcel, but that's not suitable.
The documentation for writematrix is here: https://uk.mathworks.com/help/matlab/ref/writematrix.html
TIA
Specify the range (or the starting cell) for second column using the 'Range'
property and use 'append'
for WriteMode
as shown below:
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');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.