How do I calculate the result of an aribtrary data point on a surface fitted using the fit command

4 Ansichten (letzte 30 Tage)
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

Antworten (1)

prabhat kumar sharma
prabhat kumar sharma am 4 Jul. 2024
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:
  1. 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');
  2. 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:
I hope it helps

Kategorien

Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by