importdata() question

2 次查看(过去 30 天)
Trader
Trader 2012-3-15
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?

回答(1 个)

Geoff
Geoff 2012-3-15
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 个评论
Trader
Trader 2012-3-15
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 2012-3-15
Yeah, they're the same numbers. MatLab just declutters the view a little in the command window by saying "ah well, everything's 1000x".

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by