Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: combine two cells in a string next to each other
Replies: 1   Last Post: Oct 7, 2013 2:34 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 8,845
Registered: 7/26/08
Re: combine two cells in a string next to each other
Posted: Oct 7, 2013 2:34 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Fred" wrote in message <l2s95m$oth$1@newscl01ah.mathworks.com>...
> Friends,
>
> I am writing a Tunstall message program.
>
> I want to do the following:
>
> I have A={'a1', 'a2', 'a3' 'a4' 'a5'} (You can use [] or () if needed)
>
> I want to find A(j) (Let's say j is a number between 1 and 5)
>
> Then replace A(j) with {A(j)A(1) A(j)A(2) A(j)A(3) A(j)A(4) A(j)A(5)}
>
> I want to get the following:
>
> A={'a1', 'a2', 'a3', 'a4', 'a5a1', 'a5a2', 'a5a3', 'a5a4', 'a5a5'}
>
> How could I do this?
>
> Thanks in advance. Any kind of help is appreciated.


A(5:8) = cellfun(@(s) [s A{5}], A(1:4), 'unif', 0)

% Bruno



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.