column added automatically in excel file
3 次查看(过去 30 天)
显示 更早的评论
Hello dear community,
i am trying to write those data in the excel sheet :
all the values with 6 digits (with yellow) became different : the comma shifted to the right (like 320,425 for the first yellow one), it looks like the way of writing into the excel shifted it automatically because i debugged it and i found the value before writing into the excel file are correct , any confirmation please ? if so any suggestions ?
I attached the needed files
2 个评论
Image Analyst
2021-12-3
Make it easy for people to help you. Please attach your variable in a .mat file, and give your code for writing to the workbook.
采纳的回答
Peter Bonavita
2021-12-3
Hi Nidhal,
Are the commas (,) in your data intended to represent decimal places? It seems the entry "35,5555" is intended to represent 35.5555. MATLAB uses periods to represent decimal places instead of commas. Thus, when calling xlswrite MATLAB interprets "35,5555" as 35555.
In the Excel sheet you provided, the comma shown in cell A2 is from Excel's number formatting. The raw data is shown as 355555 in the equation editor.
If you want the data to appear directly in the text file including the commas, you can use writematrix (introduced in R2019a):
% write the raw text data to a file without xlswrite
writematrix(Val,'text.xlsx')
The result from writematrix is shown below. Note that in this case, the data in Excel is displayed with the "General" format.
If the commas in your data represent decimal points, you can replace them with periods before calling xlswrite, and MATLAB will treat them as decimals:
newVal = replace(Val,",",".");
TableResult = newVal;
xlswrite(Fileoutput ,TableColumnName,1,'A1');
xlswrite(Fileoutput ,TableResult,1,'A2');
I hope this helps.
Peter
更多回答(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!