Copy variables into excel smoothly
20 次查看(过去 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!