xlsread won't read decimal numbers
Afficher commentaires plus anciens
I'm sorry if this question has already been asked, but I couldn't find a solution to my specific problem. I'm using Matlab 2014b. I'm trying to import some decimal numbers from an xlsx-excel sheet. Although my computer environment is german, the decimal numbers in the sheet do use a decimal point instead of a comma, i.e. they have the form 2.7268. However, when using [num, text, raw]=xlsread(filename, sheet, xlRange] and specifying the column I want to read, the decimal numbers are always returned as strings (text, respectively) and the num-Array is empty. The same thing happens when using the manual "Import Data" command with column vectors (and then using cell2mat on them). "Numeric matrix" replaces all values with NaN. This poses a problem as I have to use these velocity-values in a plot. Can anybody help me out? I have no idea what I'm doing wrong. Edit: My excel-sheet looks something like this:
No. #Event Time #Velocity [km/s]
1 #20140805 13:22:59.671# 2.657101# 2.657101
2 #20140805 13:23:00.483# 0.556091# 0.556091
3 #20140805 13:23:00.803# 0.590656# 0.590656
4 #20140805 13:23:03.679# 1.142748# 1.142748
5 #20140805 13:23:05.292# 1.393049# 1.393049
6 #20140805 13:23:05.382# 0.653367# 0.653367
Originally the velocity had the # attached to it (basically a string), so I used an excel-code to remove the last "decimal"(=LINKS(C13;LÄNGE(C13)-1), sorry for the German) and write the number in the column next to it, which I then tried to read. Maybe there's a reason, although the numbers shouldn't be strings anymore. However, when typing some random decimal numbers in some cells by myself the same problem still occurred.
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 8 Nov 2014
0 votes
They could be strings. If they have a ' or " in front of them they will appear as numbers but be strings. You forgot to attach the workbook so we can't inspect it for you.
2 commentaires
Ben
le 8 Nov 2014
Image Analyst
le 8 Nov 2014
It's most likely doing it because of what I said. His solution is a workaround though that will "cure" it.
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!