Simplest way to save a vector to a variable with commas and braces
조회 수: 17 (최근 30일)
이전 댓글 표시
How a can I save a numeric vector a= 1 2 3 4 5
as [1,2,3,4,5] (braces and commas are to be added here)
with a simple solution
댓글 수: 0
채택된 답변
Stephen23
2020년 2월 27일
편집: Stephen23
2020년 2월 27일
You can create a character vector:
>> strrep(mat2str(a),' ',',')
ans = [1,2,3,4,5]
which you can save however you want. But this is unlikely to be useful, or a good approach to saving data.
댓글 수: 2
Stephen23
2020년 3월 1일
The follow-up question
indicates that using standard binary/text file formats would be much simpler than this pointlessly complex way of encoding data.
참고 항목
카테고리
Help Center 및 File Exchange에서 Entering Commands에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!