I want to read each number seperated by , from my text file using Matlab. The content of the text file are as below. How can i read....

rem := [342815207237, 97439570849, 133233601810, 133188996810, 154701967396, 13\
3233601810, 263775247823, 342815207237, 352122435992, 528998419276, 53233071566\
, 550529390509, 453057544242, 530205288939, 407607331863, 342815207237, 5505293\
90509, 528998419276, 322985356485, 534086018556, 530205288939, 107542178685, 46\
3853864318, 352122435992, 342815207237, 53233071566, 177932047449, 530205288939\
, 463853864318, 453057544242, 220910979409, 300708225056, 453057544242, 5323307\
1566, 537800985017, 342815207237, 53233071566, 300708225056, 220910979409, 1779\
32047449, 342815207237].

2 件のコメント

per isakson
per isakson 2015 年 4 月 14 日
Is this one row out of many?
shilpa pund
shilpa pund 2015 年 4 月 16 日
編集済み: shilpa pund 2015 年 4 月 16 日
No.. These are many rows. Actually its an array in mupad which i had wrote in a text file. Now i want to read it from matlab and want to extract each number seperated by comma...

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

 採用された回答

Michael Haderlein
Michael Haderlein 2015 年 4 月 17 日
編集済み: Michael Haderlein 2015 年 4 月 17 日
Why not just
str=fileread('test.txt'); %read file
str=regexprep(str,'[^0-9 ]',''); %remove everything but digits and spaces
data=str2num(str); %convert to numbers
Only when things like exponential notation come into play, this will be more tricky. But to this stage, that's the easiest way I think.

1 件のコメント

shilpa pund
shilpa pund 2015 年 4 月 17 日
Thank you sir... It hepls me a lot... But it gives me the array in the form 477181869995.000 . To overcome it i used db = cast(data,'uint64'). And now i got the array as desired.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Programming についてさらに検索

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by