フィルターのクリア

Extracting data from txt file

2 ビュー (過去 30 日間)
Wai Jye Chan
Wai Jye Chan 2020 年 5 月 13 日
編集済み: Walter Roberson 2020 年 5 月 13 日
Hi, I have a raw data file where there's two variable - F & R. I would like to extract the specific value of R when F is at 5, 10, 15, 20. what should I do? Please help me with the coding. I'm new in Matlab. Thank you.
  1 件のコメント
Walter Roberson
Walter Roberson 2020 年 5 月 13 日
What does the data file look like? Please be specific about information such as whether it is tab separated columns.
Will those exact values of F appear in the file, or do you need to interpolate the values?

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

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 5 月 13 日
編集済み: Walter Roberson 2020 年 5 月 13 日
filename = 'AppropriateFileName';
data = sortrows( load(filename) );
F = data(:,1);
R = data(:,2);
probe_at = 5:5:20;
interpolated_R = interp1(F, R, probe_at);
I note that you want F at 15 and 20, which are beyond the range of F in the sample you post. If the data does not extend as far as 15 or 20 then the above code would return NaN in those positions. Extrapolation is possible by adding extra options to the interp1() call, but you should consider more about what kind of extrapolation is appropriate; I can see that you have something non-linear going on in the response.

カテゴリ

Help Center および File ExchangeVariables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by