Borrar filtros
Borrar filtros

Data Interpolation using interp1

2 visualizaciones (últimos 30 días)
Barbara Schläpfer
Barbara Schläpfer el 8 de Dic. de 2020
Comentada: Walter Roberson el 11 de Dic. de 2020
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

Respuesta aceptada

Walter Roberson
Walter Roberson el 8 de Dic. de 2020
Editada: Walter Roberson el 8 de Dic. de 2020
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 comentarios
Barbara Schläpfer
Barbara Schläpfer el 8 de Dic. de 2020
Thank you for your quick answer. Do I understand that right, that I will have to change my xFit ?
Walter Roberson
Walter Roberson el 11 de Dic. de 2020
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)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Numeric Types en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by