sfit object. can't get coefficients.

Hello. There is my code:
>> c = fit( [X, Z], Y, ft, opts );
>> c
Linear interpolant:
c(x,y) = piecewise linear surface computed from p
where x is normalized by mean 0.5 and std 0.2745
and where y is normalized by mean 227.7 and std 80.16
Coefficients:
p = coefficient structure
>> class(c)
ans =
sfit
>> coeffvalues(c)
ans =
TriangleSurfaceInterpolant with properties:
Type: 'Linear'
>> c.p
ans =
TriangleSurfaceInterpolant with properties:
Type: 'Linear'
>> c(0.3, 201)
ans =
26349
Is it possible to get coefficient of
c() function?

답변 (3개)

Greig
Greig 2015년 3월 3일

1 개 추천

As Sean de Wolski points out in the question that you linked to, a interpolated surface fit has multiple sets of linear fit coefficients, one for each point in the data.
If you want to have just a single set of coefficients for the entire surface fit you will need to use a polynomial fit. For example, if you want to use a 2nd order polynomial in both x and z, set the fittype to 'poly22'. The c.p00, c.p10, c.p01, c.p11, c.p20, c.p02 will contain all of your coefficients.
If this is not what you are looking for could you gives us some more details about what your are wanting.

댓글 수: 4

Greig, thank you for answer. See in the picture. There ar three set of points: PWM, RPS and SOC. I get this picture using result of fit() function. Now i want to get relationship: RPS and SOC ---> PWM. I mean i need to compute PWM value for pair of given SOC and RPS. I need equation to implement it in C code . And this equation should be as easy as possible. But
fit()
function can't give me this equation. Is there any matlab function to fit set of 3 variable? "...use a polynomial fit..." Did you mean
polyfit()
function?
Greig
Greig 2015년 3월 4일
편집: Greig 2015년 3월 4일
Judging by the pic, you want a linear fit in both x and y, so fit() will give you the answer. What you want is...
c = fit([SOC, RPS], PWM, 'poly11');
As before c.p00, c.p10, c.p01 are the coefficients.
This fits a linear function in both SOC and RPS, that is...
PWM = p00 + p10 * SOC + p01 * RPS
You may want to try
cftool
The interactive fitting tool, that will allow you to play around with the type of fit you use, and it displays the stat
maitehar
maitehar 2020년 6월 8일
Hello, reading this because is in the direction of what I want.
What if I want those coeficients,from a linear fit, for each fitted interval?
This is just because, by a linear fit, it simplifies a lot some calculations and allows me to propose an easy analitycal solution in my study.
Any ideas?
maitehar
maitehar 2020년 6월 8일
Ah, got it! I'lll leave it here just in case someone checks this later:
The structure with all coeficient values from a linear fit is called:
your_fit_name.p.coefs
cheers,

댓글을 달려면 로그인하십시오.

almaz ham
almaz ham 2015년 3월 3일

0 개 추천

How implement it in embedded code?

카테고리

도움말 센터File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

태그

질문:

2015년 3월 3일

댓글:

2020년 6월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by