Adrian Monk
Adrian Monk

Reputation: 73

Importing Data to Matlab

I have a csv-file with data I want to import into Matlab. Since it is a mix of date and numbers I use:

data = textscan (fid,'%s%s%n%n%n%n%n',819500,'headerlines',1,'delimiter',',');

Unfortunately, the data in column 3-7 has 5 digits and I only get 4 which is wrong, like 1.1234 instead of 1.12345.

How can I solve this?
What is wrong?

Upvotes: 0

Views: 245

Answers (1)

user1636547
user1636547

Reputation: 314

Matlab often truncates the display of numbers to four decimal places, which is what may be happening. To check this, try forcing the formatting to five decimal places using fprintf:

>>> myNum = 1.24028;
>>> fprintf("%.5f", myNum)

        1.24028

Or by changing the formatting:

>>> myNum = 1.24028;
>>> format long
>>> myNum

    myNum = 

    1.2402800000

Upvotes: 1

Related Questions