Print column vectors with different sizes

조회 수: 4 (최근 30일)
Bernd
Bernd 2012년 2월 28일
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