horzcat error while using ' '

조회 수: 2 (최근 30일)
sermet
sermet 2013년 5월 28일
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?

채택된 답변

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

추가 답변 (1개)

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

카테고리

Help CenterFile Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by