Listing only a certain value in from text file

2 ビュー (過去 30 日間)
fzhmktr
fzhmktr 2019 年 5 月 24 日
編集済み: per isakson 2019 年 5 月 24 日
I have a text file name info.txt that consist various of data. For example
car image1.png 1.524
bicycle image2.png 1.443
chair image3.png 1.823
How do i read and sort only the value of each sentence like this
1.524
1.443
1.823
Please help. Thank you.

回答 (1 件)

per isakson
per isakson 2019 年 5 月 24 日
編集済み: per isakson 2019 年 5 月 24 日
Try this
%%
chr = fileread('cssm.txt');
%%
cac = regexp( chr, '[\d\.]+(?=[\t\r ]*$)', 'match', 'lineanchors' );
num = str2double( cac );
where cssm.txt contains your text
Peek on the result
>> num
num =
1.524 1.443 1.823
>>

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by