How can I generate a comma separated list from the MATLAB vector s = [1, 2, 3, 4]?
3 次查看(过去 30 天)
显示 更早的评论
In Maple I can do the following:
s := <1, 2, 3, 4>
seq(s[i], i = 1 .. 4)
1, 2, 3, 4
How can I generate a comma separated list from the MATLAB vector s = [1, 2, 3, 4]?
0 个评论
回答(2 个)
Benjamin Thompson
2022-1-26
>> s = 1:4
s =
1 2 3 4
>> stringOut = sprintf("%d,", s)
stringOut =
"1,2,3,4,"
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!