How to get the coefficient of the function using non-linear regression analysis?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
I coded like the picture to get the coefficient of the function with data by using non-linear regression analysis. but I don't know why the errors continue. What is the problem with that??

Accepted Answer
Alan Stevens
on 4 Dec 2020
Needs to be more like this:
xm = 0:0.5:5;
ym = [0 0.223904 0.323333 0.372308 0.359143 0.332033 0.278462 0.243394 ...
0.232222 0.198334 0.172414];
a0 = [1 1 1 1 1];
a = fminsearch(@(a)fssr(a,xm,ym), a0);
disp(a)
x = linspace(0,5,100);
y = a(1)*x./(a(2) + a(3)*x + a(4)*x.^2 + a(5)*x.^3);
plot(xm,ym,'o',x,y),grid
xlabel('x'),ylabel('y')
legend('data','curvefit')
function f = fssr(a, xm, ym)
yp = a(1)*xm./(a(2) + a(3)*xm + a(4)*xm.^2 + a(5)*xm.^3);
f = norm(ym-yp);
end
9 Comments
skdfjhoiashfiWHGOFA
on 4 Dec 2020
What shoul I do just to get the coefficient without plotting?
skdfjhoiashfiWHGOFA
on 4 Dec 2020
sorry *should
skdfjhoiashfiWHGOFA
on 4 Dec 2020
Oh I get it!
thank you
Just delete the plotting from the above if you don't want it. The
disp(a)
command displays the values of a in the command window.
skdfjhoiashfiWHGOFA
on 4 Dec 2020
I'm so sorry to keep asking, but how to get the maximum value of that function?
Alan Stevens
on 4 Dec 2020
Just use
max(y)
skdfjhoiashfiWHGOFA
on 4 Dec 2020
I've already done that but there's an error...
Alan Stevens
on 4 Dec 2020
What's the error? When I do it I get 0.3673 for the max value.
skdfjhoiashfiWHGOFA
on 4 Dec 2020
I solved it. I get that one too. Thank you sooo much !!
More Answers (0)
Categories
Find more on Linear Predictive Coding in Help Center and File Exchange
See Also
on 4 Dec 2020
on 4 Dec 2020
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)