How to change precision using cellfun and num2str
조회 수: 3 (최근 30일)
이전 댓글 표시
I'm trying to convert a column of data into a column of strings. I've used the cellfun function:
data_compiled=compiled_data_import('data compiled.csv');
timestamps=cellfun(@num2str,data_compiled(:,1),'UniformOutput', false);
And that works but the output is rounding off too soon. I know you can specify precision when using num2str but I don't know what to put in for the first argument of num2str since I call the numbers to convert in the cellfun function.
Would it be something like:
data_compiled=compiled_data_import('data compiled.csv');
timestamps=cellfun((x)@num2str(x,3),data_compiled(:,1),'UniformOutput', false);
? Please help.
댓글 수: 0
채택된 답변
Walter Roberson
2016년 2월 19일
Very close.
timestamps=cellfun(@(x) num2str(x,3),data_compiled(:,1),'UniformOutput', false);
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!