Is there a way to fit experimental data to a set of x,y points?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Todd Fayard
el 20 de Jul. de 2023
Comentada: Star Strider
el 24 de Jul. de 2023
I have obtained experimental data and would like to fit it to a first order Hankel function. I have the specific Hankel function as a set of [x,y] points in a csv file and would like to fit my experimental data to this plot. Is there a way to do this in Matlab? I'm familar with matlab curve fitting, but im not sure how to fit data to x,y points.

0 comentarios
Respuesta aceptada
Star Strider
el 21 de Jul. de 2023
Editada: Star Strider
el 22 de Jul. de 2023
I suppose that you could fit those using the first argument ν as the parameter to be estimated, with z being the independent variable.
That objective function would be something like this:
H1fcn = @(nu,z) besselj(nu,z) + 1i*bessely(nu,z);
although I have my rervations as to how it would work, given the imaginary operator. It might be necessary to enclose it within the abs function. I leave those details to you.
EDIT — (22 Jul 2023 at 17:02)
Corrected typographical errors, attempted data reconstruction and nonlinear fit —
x = linspace(1E-4, 0.25, 100).'; % Create Data
y = 650*exp(-150*x); % Create Data
H1fcn = @(nu,z) besselj(nu,z) + 1i*bessely(nu,z); % First-Order Hankel Function
mdl = fitnlm(x,y,@(nu,z)abs(H1fcn(nu,z)), 1) % Fit Function To Data
B = mdl.Coefficients.Estimate;
figure
plot(x, y, '.', 'DisplayName','Data (Synthetic)')
hold on
plot(x, abs(H1fcn(B,x)), 'DisplayName','Function Fit')
hold off
grid
xlabel('X')
ylabel('Y')
title('First-Order Hankel Function: Fit to Simulated Data')
legend('Location','best')
You might be able to get a better fit with the actual data.
.
2 comentarios
Más respuestas (2)
the cyclist
el 20 de Jul. de 2023
If you have the Statistics and Machine Learning Toolbox, you should be able to do this type of fit with fitnlm (or possibly fitlm).
If you want more detailed help, please post your data (using the paper clip icon in the INSERT section of the toolbar), and the form of the equation you are trying to fit.
2 comentarios
the cyclist
el 20 de Jul. de 2023
Immediately after I posted this answer, I realized that I don't really understand what "I have the specific Hankel function as a set of [x,y] points in a csv file" means. The (x,y) points and the experimental are two different things?
the cyclist
el 22 de Jul. de 2023
Informed by your comments on my other answer, I have a different one. Unfortunately, that answer is "What you are asking to do is not sensible". This forum is not the easiest way to explain why, but I'll try. We need to step through a few concepts.
First, note how you say you want to "fit my experimental data to this plot". This is backward. You do not fit experimental data to something. You fit something (usually a function) to the data. This may seem like nit-picky English, but it is crucial to the reason why your question is not sensible.
Second, think about what it specifically means to fit a function to experimental data. Let's take the easy case of fitting a straight line to data. What does it mean to "fit"? In the case of fitting a line to data, it means finding the values of the two free parameters of the line (the intercept and slope) that give the minimum error between the line and the data. The fitting process is the finding of the best parameters. (This would also be true if you were fitting a more complex function.)
Finally, considering your question, of "fitting" a fixed set of points to a fixed set of experimental data. You have a problem. There are no free parameters. You cannot fit the (x,y) points to the data, because there is nothing to tune.
Perhaps there is something I am misunderstanding, or perhaps there is some important aspect of your problem that you have not told us here. But as stated, the problem is not solvable.
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox 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!

