How do I calculate the result of an aribtrary data point on a surface fitted using the fit command
2 次查看(过去 30 天)
显示 更早的评论
INPUT X Array (24,1) data points
INPUT Y Array (24,1) data points
OUTPUT Array (24,1) data points
use
[FO, G] = fit([X, Y],Z,'linearinterp') to fit the surface
can extract the Y value in MATLAB for any arbitrary point on the surface using for example, FO(x1,y1) to give me an answer z1
If I need to extract the value of any arbitrary data point WITHOUT MATLAB where are the coefficients available for me to calculate the output?
The explanation of how to extract the coefficients from a fit command seem extremely sparse!
Many thanks in advance
回答(1 个)
prabhat kumar sharma
2024-7-4
Hi Branko,
When you are working with a fitted surface in MATLAB, you can extract the coefficients directly from the cfit or sfit object. These coefficients represent the parameters of the fitted function. Here’s how you can obtain the coefficient values:
- First, fit your data using the fit function. For example, if you have a linear interpolation fit, you can use:[FO, G] = fit([X, Y], Z, 'linearinterp');
- To retrieve the coefficient values, use the coeffvalues function on the fitted object (FO in this case):coefficientValues = coeffvalues(FO); The coefficientValues will be a vector containing the coefficients corresponding to the fitted function. You can then use these coefficients to calculate the output value for any arbitrary data point without MATLAB.
Remember that the number of coefficients depends on the type of fit (e.g., linear, quadratic, etc.). If you’re fitting a polynomial, you’ll have coefficients like p1, p2, etc., as shown in the example. Feel free to adapt this approach to your specific fit type!
You can refer all these docuemntations for your reference:
- https://www.mathworks.com/help/curvefit/cfit.coeffvalues.html
- https://www.mathworks.com/matlabcentral/answers/63178-how-can-i-extract-the-parameters-from-curve-fitting-fit-function
I hope it helps
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!