i have array like this a = 50 60 70 80 and want to make each entity comma seperated i.e 50,70,80,90 how i can do this?

조회 수: 1 (최근 30일)
it can be done by concetnation method?
  댓글 수: 1
Jan
Jan 2013년 7월 23일
Neither the input nor the output is defined exactly. I guess that the input is a numerical vector like:
a = [50, 60, 70, 80]
and the output should be a string:
s = '50, 60, 70, 80'
I assume, that the omitted '60' and the added '90' is a typo only.
Please be as exact as possible, when you ask a question in the forum. Guessing the details means usually a waste of your and out time. Thanks.

댓글을 달려면 로그인하십시오.

채택된 답변

Narges M
Narges M 2013년 7월 23일
A= [20,30,40,50]';
comma = ones(size(A))* ',';
B = [num2str(A) char(comma)];

추가 답변 (1개)

Jan
Jan 2013년 7월 23일
a = [50, 60, 70, 80]
s = sprintf('%d, ', a);
s(end-1:end) = []; % Remove the trailing ', '

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by