필터 지우기
필터 지우기

Data Interpolation using interp1

조회 수: 2 (최근 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

채택된 답변

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 CenterFile Exchange에서 Numeric Types에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by