Fitting a model to a displacement field
Afficher commentaires plus anciens
Hi!
I have aquired a displacement field from image analysis and i want to fit a model to the field in order to be able to derive the strain.
I tried to interpolate between the points to find a function that fits but the results are not good.
The attached file contains the coordinates of the feature before (column 1 and 2) and the coordinates of the same feature after (column 3 and 4) so that for example row 1 contains the x and y coordinates of the feature before and after.
Any suggestions on where to start would be greatly appriciated.
Regards,
3 commentaires
Andreas Apostolatos
le 30 Mar 2021
Hello,
Your data in file 'Coordinates before and after .csv' contain NaNs, these values cannot be used for the interpolation. Therefore, the NaN values would first need to be removed from your dataset.
You provided a list of the X-Y coordinates before and after the deformation at particular locations. Do these coordinates correspond to an 1D or to a 2D body? If they correspond to a 2D body, then are the data scattered or gridded? This knowledge is necessary in order to use the right MATLAB function for your needs.
Kind Regards,
Andreas
Holmbrero
le 30 Mar 2021
Holmbrero
le 30 Mar 2021
Réponses (1)
Nipun
le 22 Mai 2024
Hi Holmbrero,
I understand that you are trying to fit a model to a displacement field derived from image analysis to calculate strain. Given the coordinates before and after deformation, you can use polynomial fitting to model the displacement and then derive strain components from this model.
Here is a MATLAB approach to accomplish this:
% Assuming 'data' is a matrix where columns 1 and 2 are the initial (x, y) coordinates,
% and columns 3 and 4 are the final (x', y') coordinates
x = data(:,1);
y = data(:,2);
xp = data(:,3); % x prime (x')
yp = data(:,4); % y prime (y')
% Calculate displacement vectors
u = xp - x; % Displacement in x direction
v = yp - y; % Displacement in y direction
% Fit polynomial models to the displacement fields
% Adjust 'poly11' for higher order polynomials if needed
ft_u = fittype('poly11'); % Polynomial type for u
ft_v = fittype('poly11'); % Polynomial type for v
% Perform the fitting
[fitresult_u, gof_u] = fit([x, y], u, ft_u);
[fitresult_v, gof_v] = fit([x, y], v, ft_v);
% Display the fit results
disp('Fit for u (x displacement):');
disp(fitresult_u);
disp('Fit for v (y displacement):');
disp(fitresult_v);
% Assuming a linear model, calculate strain components
% For more complex models, differentiate accordingly
epsilon_xx = diff(fitresult_u, x, 'x'); % ∂u/∂x
epsilon_yy = diff(fitresult_v, y, 'y'); % ∂v/∂y
gamma_xy = diff(fitresult_u, y, 'y') + diff(fitresult_v, x, 'x'); % ∂u/∂y + ∂v/∂x
% Note: differentiate is a placeholder function for the concept of differentiation. In practice, you need to
% extract the coefficients from the fit results and manually calculate the derivatives for your specific polynomial model.
For more information on "fittype" and "diff" functions in MATLAB, refer to the following MathWorks documentation:
- "fittype" function : https://in.mathworks.com/help/curvefit/fittype.html
- "diff" function : https://in.mathworks.com/help/symbolic/diff.html
Hope this helps.
Regards,
Nipun
Catégories
En savoir plus sur Linear and Nonlinear Regression dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!