Problem 41. Cell joiner
You are given a cell array of strings and a string delimiter. You need to produce one string which is composed of each string from the cell array separated by the delimiter.
For example, this input
in_cell = {'Lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur'}; delim = ' ';
should produce this output:
out_str = 'Lorem ipsum dolor sit amet consectetur';
Solution Stats
Problem Comments
-
12 Comments
There has been a function added in 2013a for this!!
I make it in R2013a,but I don't know the R2012b or other previous versions have this function.
Most of the solutions consider that delim=1char
i don't know
tricky one!!
nicequestion
Hello everyone :)
Just a quick one: the code I provide below here work fine in Matlab (r2019b), so each solution matches the one I'm asked to provide. However, when evaluating the code on Cody, I get "Assertion failed".
Can anyone please explain me if it's a matter of conversion or some details I am missing?
KR, Andrea
out_str=[];
for jj=1:length(in_cell)
tmp=char(in_cell(jj));
c=[tmp,delim];
if jj==1
out_str=c;
else
out_str=[out_str,c];
end
end
I used strjoin(in_string,' ')
passed the first two, third one failed.
no way for me
nice biology concept
This one is kinda hilarious, as (hint here) it may punish you for defining TOO much...
cool problem!
Solution Comments
Show commentsProblem Recent Solvers6116
Suggested Problems
-
Increment a number, given its digits
650 Solvers
-
Given a matrix, swap the 2nd & 3rd columns
1072 Solvers
-
760 Solvers
-
Who has power to do everything in this world?
442 Solvers
-
14722 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!