Copy variables into excel smoothly
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
C B
il 21 Apr 2023
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
Risposta accettata
Stephen23
il 21 Apr 2023
Modificato: Stephen23
il 21 Apr 2023
"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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!