Trying to Find a Value associated with another value

3 ビュー (過去 30 日間)
Nakarsha
Nakarsha 2014 年 3 月 27 日
コメント済み: Nakarsha 2014 年 3 月 27 日
I have a data file that has two columns. In the first column I have a set of data the reads 1-2000 then there is a space and it begins again at 1. This repeats for 372 times. I am trying to determine how to write a script or a function so I can extract data associated with lets say the data for 150 in each of the sets. For example, Matlab ask for x and I input 150 my output is then every value the is on the same row as 150 in each of the 372 sets of data. PLEASE HELP!! I am new to Matlab and confused. Thanks

回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 3 月 27 日
filestr = fileread('YourFile.txt');
matched_strs = regexp(filestr, '(?:^150\s+).*$', 'match', 'lineanchors', 'dotexceptnewline');
matched_vals - str2double(matched_strs);
  4 件のコメント
Nakarsha
Nakarsha 2014 年 3 月 27 日
I types the last command you gave me and it return just another >>. Did I do something wrong or am I missing some more commands
Nakarsha
Nakarsha 2014 年 3 月 27 日
It finally said 'Not enough memory to read file contents: Java heap space'

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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by