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?

2 views (last 30 days)
it can be done by concetnation method?
  1 Comment
Jan
Jan on 23 Jul 2013
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.

Sign in to comment.

Accepted Answer

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

More Answers (1)

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

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!