From: CLou on 30 Jun 2010 14:47 "Jos (10584) " <#10584(a)fileexchange.com> wrote in message <i0g37s$7rm$1(a)fred.mathworks.com>... > "CLou " <cathy(a)prismstoneconsultingTO.com> wrote in message <i0g266$s6s$1(a)fred.mathworks.com>... > > Hi, > > > > I'm trying to concat a string to each string in a cell array of strings using: > > > > first = 'first_' > > attach = { 'end' 'end1' 'end31' } > > i=1:1:size(attach,2) > > cellfun( @(x) [first x(i) ], attach, 'UniformOutput',false) > > > > It works, except that all of the values in attach are truncated to 'end'. How do I prevent that from happening? > > > > Thanks! > > > > Cathy > > Why do it the hard way? ML offers some excellent string functions, like STRCAT: > > first = 'first_' > attach = { 'end' 'end1' 'end31' } > result = strcat(first,attach) > > hth > Jos Thanks, Jos
From: CLou on 30 Jun 2010 14:54 "CLou " <cathy(a)prismstoneconsultingTO.com> wrote in message <i0g3fa$mkr$1(a)fred.mathworks.com>... > "Jos (10584) " <#10584(a)fileexchange.com> wrote in message <i0g37s$7rm$1(a)fred.mathworks.com>... > > "CLou " <cathy(a)prismstoneconsultingTO.com> wrote in message <i0g266$s6s$1(a)fred.mathworks.com>... > > > Hi, > > > > > > I'm trying to concat a string to each string in a cell array of strings using: > > > > > > first = 'first_' > > > attach = { 'end' 'end1' 'end31' } > > > i=1:1:size(attach,2) > > > cellfun( @(x) [first x(i) ], attach, 'UniformOutput',false) > > > > > > It works, except that all of the values in attach are truncated to 'end'. How do I prevent that from happening? > > > > > > Thanks! > > > > > > Cathy > > > > Why do it the hard way? ML offers some excellent string functions, like STRCAT: > > > > first = 'first_' > > attach = { 'end' 'end1' 'end31' } > > result = strcat(first,attach) > > > > hth > > Jos > > Thanks, Jos ....should also say this code is taken from a larger body of code where I was already using vectorization for other manipulations. Guess I got carried away... :)
First
|
Prev
|
Pages: 1 2 Prev: writing values into excel column wise Next: Changing The Polar Axis Values |