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
Walter Roberson
2022년 1월 27일
s = 1:4;
ExpandCell = @(C) C{:};
[A,B,C,D] = ExpandCell(num2cell(s))
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!