|
In article <fonf4q$t6n$1@fred.mathworks.com>,
Christian Kuijlaars <c.a.j.kuijlaars@student.tudelft.nl> wrote:
>at the moment I have a structure in this form
>str.A
>str.B
>str.C
>A and B always contain only one string array. But C might
>contain multiple. What I want is to produce a matrix that
>looks like this
>1 A B C
>2 A B C C C
>3 A B C C C C C C C
>4 A B C C
>5 A B C
>6 A B C C C C
>etc
Are we to understand that you want to produce a matrix in
which the K'th element is str(K).A str(K).B str(K).C
>Now the first part is easy, I make two vectors of A and B
>and add those to the cell array. But to construct the
>matrix for C is an entirely different matter. I now can do
>it with a for loop but as those slow down the process I was
>wondering wether this was simply possible with logical
>indexing? I've tried
>
>vec = str(1).C';
>y(1) = vec;
>
>however that gives the error that the number of elements
>must be the same.
>I can do y{1} = vec; but that gives me a cell in a cell and
Sorry, you need to be clearer on exactly what type str.A
and str.B and str.C are, and exactly what type of output
you are attempting to create.
You say that A and B always contain only one string array.
Are str.A and str.B cell string arrays, or are they
character arrays of a single row each, or are they character
arrays with multiple rows and columns per entry? If
str(K).A has a different number of rows than str(K).B then
how do you want the output to be created?
>the purpose of y is to import it in Excel through excel
>link.
Is each entry in y(K) intended to be the string formed
by concatenating str(K).A then str(K).B then all of the
rows of str(K).C in order; with no spaces or delimeters
between the elements?
I have never used the excel COM object link. I do know, though,
that when you use csvwrite or dlmwrite that unless you are careful
and manage the excel cell delimeters yourself, Matlab will write
each character into its own cell. I do not know if that can be
gotten around with the excel COM link.
Your reference to "a cell in a cell" implies that you are forming
y as a cell array instead of as a character array. Does the excel
COM object allow you to send through cell arrays of any form?
Or will you need to conver it all to a character array before
sending it to excell?
--
"The slogans of an inadequate criticism peddle ideas to fashion"
-- Walter Benjamin
|