Copy variables into excel smoothly
조회 수: 17 (최근 30일)
이전 댓글 표시
I have a variable A:
24.3712410000000
24.2311330000000
23.4083360000000
24.2096500000000
23.6800080000000
23.2512100000000
23.5765810000000
24.1315920000000
23.4942910000000
24.3568280000000
I want to copy this into excel, however excel does not view these as numbers since comma in excel is "," not "."
So I wonder how I can work around this? I also want the values to have two decimals:
In excel it should look like this:
24,37
24,23
23,41
etc.
댓글 수: 2
C B
2023년 4월 21일
one way if he dont want to change locale and still need to do this then he can conver this to string or just add
'24,37
like this in this way excel dont apply formatting, please correct me if i am wrong
채택된 답변
Stephen23
2023년 4월 21일
편집: Stephen23
2023년 4월 21일
"So I wonder how I can work around this?"
Don't copy-paste data into Excel. The simple, easy, robust approach is to use WRITEMATRIX:
If you really must copy-paste data then you will need to change the decimal radix character... you could either do this within Excel (e.g. paste as text, replace char, paste special) or within MATLAB, e.g.:
V = [24.371241;24.231133;23.408336;24.20965;23.680008;23.25121;23.576581;24.131592;23.494291;24.356828]
C = strrep(compose('%#.8g',V),'.',',');
fprintf('%s\n',C{:})
"In excel it should look like this"
I recommend exporting the data at its full precision, and only changing the display precision in Excel.
Note that whether MS Excel displays numeric data with a decimal comma or a decimal point depends entirely on your locale settings. The locale settings make absolutely no difference to the numeric data stored in the Excel file.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!