Thread Subject: One string from cell array of strings?

Subject: One string from cell array of strings?

From: Jari Kokkonen

Date: 21 Oct, 2008 07:30:04

Message: 1 of 3

Hello all!

I've got a problem I've been working on. I have unspecified amount of cells and I want to make one string from the array.I've made the array (AB) with cells (strings):

ab1 -cell 1
, -cell 2
ab2 -cell 3
, -cell 4
.
.
abn -cell n

I would like to convert this array to string:
ab1,ab2,...,abn -cell 1

which I will input to mintersect (intersect, which accepts multiple inputs).

Same_coordinates=mintersect(ab1,ab2,...,abn);

I've tried strcat, which will not work because I can't make an input of

AB_string=strcat(AB(1,:));

because strcat does not understand it and I can't just tell strcat which to concenetate because I don't know exact amount of cells.

Hopefully someone can give me a hand.

With best regards
Jari Kokkonen

Subject: One string from cell array of strings?

From: Kris De Gussem

Date: 21 Oct, 2008 12:14:42

Message: 2 of 3

Jari Kokkonen schreef:
> Hello all!
>
> I've got a problem I've been working on. I have unspecified amount of cells and I want to make one string from the array.I've made the array (AB) with cells (strings):
>
> ab1 -cell 1
> , -cell 2
> ab2 -cell 3
> , -cell 4
> .
> .
> abn -cell n
>
> I would like to convert this array to string:
> ab1,ab2,...,abn -cell 1
>
> which I will input to mintersect (intersect, which accepts multiple inputs).
>
> Same_coordinates=mintersect(ab1,ab2,...,abn);
>
> I've tried strcat, which will not work because I can't make an input of
>
> AB_string=strcat(AB(1,:));
>
> because strcat does not understand it and I can't just tell strcat which to concenetate because I don't know exact amount of cells.
>
> Hopefully someone can give me a hand.
>
> With best regards
> Jari Kokkonen
>
>
Hi Jari

It is not clear to me what you want to do.
Maybe something similar to?:
    cat(2, AB{:})
    cat(2, AB{1,:}
    sprintf ('%s,',t{2,:})

Hope this helps.

Regards
K.

Subject: One string from cell array of strings?

From: Pekka Kumpulainen

Date: 23 Oct, 2008 07:28:01

Message: 3 of 3

"Jari Kokkonen" <plaa@plaa.plaa> wrote in message <gdk0ds$5a7$1@fred.mathworks.com>...
> Hello all!
>
> I've got a problem I've been working on. I have unspecified amount of cells and I want to make one string from the array.I've made the array (AB) with cells (strings):
>
> ab1 -cell 1
> , -cell 2
> ab2 -cell 3
> , -cell 4
> .
> .
> abn -cell n
>
> I would like to convert this array to string:
> ab1,ab2,...,abn -cell 1
>
> which I will input to mintersect (intersect, which accepts multiple inputs).
>
> Same_coordinates=mintersect(ab1,ab2,...,abn);
>
> I've tried strcat, which will not work because I can't make an input of
>
> AB_string=strcat(AB(1,:));
>
> because strcat does not understand it and I can't just tell strcat which to concenetate because I don't know exact amount of cells.
>
> Hopefully someone can give me a hand.
>
> With best regards
> Jari Kokkonen
>

Is this what you are looking for??
AB = {'ab1';'ab2';'ab3'};
then a function call
myfunc(AB{:})
is equal to myfunc('ab1','ab2','ab3')

For more type "comma separated list" to search the Help. Look for topics
How to Use the Comma-Separated Lists
and under that to
Function Call Arguments

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com