이 제출물을 팔로우합니다
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다
When exporting a matrix of numbers for display in another program (eg. using xlswrite()), it may be useful to apply a format, such as limiting the number of decimals or adding external commands.
matlab limitations:
- xlswrite() does not have a format option.
- num2str() converts a row into a single string, which exports as one character per cell.
- num2str() can't be applied to a cell array.
This simple function converts each element to a character cell in an array using arrayfun() and a nested function that applies the format string with num2str().
Option: add the optional argument 'sparse' to convert 0 values to blank cells using cellfun() and a nested function.
The nested functions use variables available to the parent function.
sample run:
A = rand(3,5); A(2,1:3) = 0; % table with a few 0 values
txtA = makeTextTable(A,'%.2f'); % convert to text with 2 decimals
txtA = makeTextTable(A,'%.2f','sparse'); % convert to text with 2 decimals (no zeros)
인용 양식
Renee (2026). Converting a matrix to formatted text (https://kr.mathworks.com/matlabcentral/fileexchange/37169-converting-a-matrix-to-formatted-text), MATLAB Central File Exchange. 검색 날짜: .
| 버전 | 퍼블리시됨 | 릴리스 정보 | Action |
|---|---|---|---|
| 1.0.0.0 |
