horzcat error while using ' '

3 Ansichten (letzte 30 Tage)
sermet
sermet am 28 Mai 2013
names=['john'; 'ravi'; 'mary'; 'xiao']
howdy=char('10', '20', '30' ,'40')
result=[howdy, ' ', names] % ' ' in order to seperate columns
I wanna create result as
john 10
ravi 20
mary 30
xiao 40
but result=[howdy, ' ', names] gives horzcat error. How can I fix this?

Akzeptierte Antwort

Iman Ansari
Iman Ansari am 28 Mai 2013
names=['john'; 'ravi'; 'mary'; 'xiao']
howdy=['10'; '20'; '30' ;'40']
result=[names repmat(' ',4,1) howdy]

Weitere Antworten (1)

Andrei Bobrov
Andrei Bobrov am 28 Mai 2013
names={'john'; 'ravi'; 'mary'; 'xiao'}
howdy=(10:10:40)';
result = strcat(names,{' '},num2str(howdy));

Kategorien

Mehr zu Time-Frequency Analysis finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by