Combining to two Cells
Mostra commenti meno recenti
I 've scouring the web to find a solution but not much success
p = [{2323}]; k = {'hello'};
where I want pk = {'2323hello'}
Pretty much what the concatenate function in excel would do.
Thanks, Stephan
Risposta accettata
Più risposte (2)
Star Strider
il 13 Gen 2016
Using sprintf is one option:
p = {2323}; k = {'hello'};
pk = {sprintf('%d%s', p{:}, char(k))}
pk =
'2323hello'
Vaibhav Awale
il 13 Gen 2016
1 voto
Hi,
This can be done using the following command:
>> pk = {[num2str(p{:}), k{:}]}
Refer to following documentation for more information about how cell array indexing works:
Hope this helps.
Regards,
Vaibhav
2 Commenti
Stephan Richtering
il 13 Gen 2016
Vaibhav Awale
il 13 Gen 2016
Hi Stephan,
Interestingly "num2str" function returns the string if you give string as an input. So, this approach would work even when "p" is a string!
Regards,
Vaibhav
Categorie
Scopri di più su Data Type Conversion in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!