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
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.
采纳的回答
更多回答(1 个)
Jan
2013-7-23
a = [50, 60, 70, 80]
s = sprintf('%d, ', a);
s(end-1:end) = []; % Remove the trailing ', '
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!