- Versions R2016a and before: The output is a 1xN char array.
- Versions R2016b and later: The output class is the same as that of the first input.
Output of sprintf - string?
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi everyone,
on Matlab's documentation I read that sprintf is a function which takes as input data and returns a string. If I write:
x=sprintf('%d',2222)
the output has 1x4 dimension, thus is a character array and not a string (i use Matlab 2015). Why?
Thank you.
댓글 수: 0
채택된 답변
Stephen23
2017년 5월 11일
편집: Stephen23
2018년 1월 16일
Because MATLAB only introduced the string class in R2016b, but previously any character array with size 1xN was called a "string". So for historic reasons there are many references to "strings" that are actually references to 1xN char arrays.
For example this includes the functions sprintf, cellstr, and iscellstr.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!