importdata() question

1 Ansicht (letzte 30 Tage)
Trader
Trader am 15 Mär. 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?

Antworten (1)

Geoff
Geoff am 15 Mär. 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 Kommentare
Trader
Trader am 15 Mär. 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 am 15 Mär. 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".

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by