How can I generate a comma separated list from the MATLAB vector s = [1, 2, 3, 4]?
1 view (last 30 days)
Show older comments
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 Comments
Answers (2)
Benjamin Thompson
on 26 Jan 2022
>> s = 1:4
s =
1 2 3 4
>> stringOut = sprintf("%d,", s)
stringOut =
"1,2,3,4,"
0 Comments
Walter Roberson
on 27 Jan 2022
s = 1:4;
ExpandCell = @(C) C{:};
[A,B,C,D] = ExpandCell(num2cell(s))
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!