Print column vectors with different sizes

4 次查看(过去 30 天)
Hello,
I've got the following problem, but wasn't able got find a solution so far:
A program analyses some data and prints out the results as csv-files which contain one column vector with arbitrary size. I want to write a script which reads some of the csv-files and prints the vectors into one new csv-file, while the heading contains the filename
#Input from first file:
a = [1;2;3];
filename = "aaa";
A = [A, a];
file = strcat(file, ",", filename);
#Input from second file:
a = [1;2;3;4;5];
filename = "bbb";
A = [A, a]; # Here the error occurs
file = strcat(file, ",", filename);
When I do it like this I get the error that the size of the matrix doesn't match. Resizing the matrix and padding it with 0 isn't an option as it would give wring results in the later run. I found the "append" option for csvwrite, but it only works with appending lines, not with appending columns.
Has anybody an idea how to print columns with different lengths into an csv-file?
Regards
Bernd

回答(1 个)

Walter Roberson
Walter Roberson 2012-2-28
csvwrite() and dlmwrite() are not appropriate commands for your purpose.

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by