필터 지우기
필터 지우기

importdata() question

조회 수: 1 (최근 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