Data Interpolation using interp1

5 ビュー (過去 30 日間)
Barbara Schläpfer
Barbara Schläpfer 2020 年 12 月 8 日
コメント済み: Walter Roberson 2020 年 12 月 11 日
Hi
I am trying to interpolate different data sets, so that they all have the same size for my further analysis.
maxLength = max([length(unique_expperimental_dis), length(unique_experimental_force), length(abaqus_force)]);
xFit = 1:maxLength;
experimental_dis_interp = interp1(1:length(unique_expperimental_dis), unique_expperimental_dis, xFit);
size('experimental_dis_interp')
experimental_force_interp = interp1(1:length(unique_experimental_force), unique_experimental_force, xFit);
size('experimental_force_interp')
abaqus_force_interp = interp1(1:length(abaqus_force), abaqus_force, xFit);
size('abaqus_force_interp')
But wenn I read out the sizes of the different data sets, they do not match eachother. Any suggestions what I am doing wrong?
Barbara
  1 件のコメント
Star Strider
Star Strider 2020 年 12 月 8 日

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

採用された回答

Walter Roberson
Walter Roberson 2020 年 12 月 8 日
編集済み: Walter Roberson 2020 年 12 月 8 日
maxLength = max([length(unique_expperimental_dis), length(unique_experimental_force), length(abaqus_force)]);
xFit = 1:maxLength;
experimental_dis_interp = interp1(1:length(unique_expperimental_dis), unique_expperimental_dis, xFit);
size(experimental_dis_interp)
experimental_force_interp = interp1(1:length(unique_experimental_force), unique_experimental_force, xFit);
size(experimental_force_interp)
abaqus_force_interp = interp1(1:length(abaqus_force), abaqus_force, xFit);
size(abaqus_force_interp)
You were calculating the size() of the character vectors, not the variables.
Caution: you have not turned on extrapolation, so the above code is equivalent to padding the short vectors with NaN.
  2 件のコメント
Barbara Schläpfer
Barbara Schläpfer 2020 年 12 月 8 日
Thank you for your quick answer. Do I understand that right, that I will have to change my xFit ?
Walter Roberson
Walter Roberson 2020 年 12 月 11 日
If padding with NaN was not your intention, then you need to be more clear about your desired outcome.
If you have two variables in which there is a linear relationship between the two, so (say) 2/3 of the way through the range of one should correspond to 2/3 of the way through the range of the other, then you can scale between them:
fraction_through_first_range = (value_in_first_range - minimum_of_first_range) / (maximum_of_first_range - minimum_of_first_range);
projected_into_second_range = minimum_of_second_range + (maximum_of_second_range - mininum_of_second_range) * fraction_through_first_range
Is it really the number of different entries in a group that matters to you, or are you wanting to project by portion of the way through the respective range?
linspace(unique_expperimental_dis(1), unique_expperimental_dis(end), maxLength)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by