importdata() question

3 views (last 30 days)
Trader
Trader on 15 Mar 2012
I need help understanding what's happening here, any input would be appreciated.
Here is my code:
import1 = importdata('Historical_Data/ES.csv');
price_low=import1.data(:,1);
I'm reading a .csv file with values like the following
Date,Low
2/17/12,1353
2/16/12,1334.25
2/15/12,1338
2/14/12,1337.75
The values are being save to my array as
1.3530
1.3342
1.3380
1.3377
I'd like the value to be the same as they are in the file.
Is this an ASCII issue?

Answers (1)

Geoff
Geoff on 15 Mar 2012
Are you sure? If you look closely, you'll see the display is saying '1.0e+003 *'. That means your numbers are correct, but are being shown in scientific form.
If you really want them to look identical to the input file, read them as strings with textread:
filename = 'Historical_Data/ES.csv';
[mydate, myval] = ...
textread( filename, '%s%s', 'headerlines', 1, 'delimiter', ',' );
  2 Comments
Trader
Trader on 15 Mar 2012
if I type price_low in the command window I get:
price_low =
1.0e+03 *
1.3530
1.3342
1.3380
1.3377
In the variable editor it shows:
1.3548e+03
1.3418e+03
...
Geoff
Geoff on 15 Mar 2012
Yeah, they're the same numbers. MatLab just declutters the view a little in the command window by saying "ah well, everything's 1000x".

Sign in to comment.

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!