How to read character(numeric data) from text file as how it is displayed without rounding up values

1 回表示 (過去 30 日間)
Sophie
Sophie 2018 年 9 月 24 日
編集済み: Stephen23 2018 年 10 月 12 日
Hi I would like to read off a text file at location 414 from the beginning of file,it consists of 0.31158E+02 -0.15094E+03 -0.13590E-04 I would like to read the first character from the text file as how it is given but I can only obtain a rounded up value of 32 instead of 0.31158E+02 . How can I go about this?
fid=fopen('textfile.m');
>> fseek(fid,414,'bof');
>> X=fread(fid,1,'schar')
X = 32
  1 件のコメント
Stephen23
Stephen23 2018 年 10 月 12 日
編集済み: Stephen23 2018 年 10 月 12 日
"... I can only obtain a rounded up value of 32..."
Most probably that is a space character, which has nothing to do with your number at all.

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2018 年 9 月 25 日
Read about format
format long should work.

カテゴリ

Help Center および File ExchangeLow-Level File I/O についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by