least square fitting for a nonlinear regression.

조회 수: 8 (최근 30일)
chaitanya vallabh
chaitanya vallabh 2022년 7월 19일
편집: John D'Errico 2022년 7월 19일
I have set of data points of anugular displacement and time. With which i plotted a sine wave graph. I have this equation y(t) = yˆ0 · e −δt ·sin(ω t +ϕ) +B. Now i have to put this equation into the sine wave graph and find out the five unknows yˆ0, δ, ω, ϕ & B. How can i write the code for this using least square fitting.

답변 (2개)

Image Analyst
Image Analyst 2022년 7월 19일
Did you try fitnlm? I'm attaching some demos, though I don't have one with a sine wave but it might work if you adapt one of them, like the exponential decay one.

John D'Errico
John D'Errico 2022년 7월 19일
편집: John D'Errico 2022년 7월 19일
You show no data, and only a difficult to understand equation, but I am pretty sure what form you are trying to fit.
y(t) = yˆ0 · e −δt ·sin(ω t +ϕ) +B
This was what you wrote. Does the e there mean to indicate e^x, so the exponential function? Likely it does. In that case, you have a damped sine wave, to a constant offset. A pretty basic model. But since we see no data, it is impossible to know if your data even rationally supports that model. Sadly, it is often the case that is false. And do you have sufficient data to fit such a model? Again, we see no data.
However, anytime you want to fit a sine function of a form like that, you need to understand how to estimate the parameters in the model, since if you provide poor estimates of the parmeters, you will get crap for a result. It is often true that for many problems, being off by a factor of 2 in the size of a parameter estimate is not a problem. But here, that is not the case. sine waves are tricky in that respect. If you are wrong in your estimate of w by a factor of 2, you will probably see a failed result in the fit.
A simple way to fit such a model is to use the curve fitting toolbox. But again, we don't know what toolboxes you have, sicne you can fit a model using tools from the optimization TB, the Stats TB, the Global optimization TB, and, of course, the Curve Fitting TB. And you can do a fit without any toolbox at all.
If you show your data, and tell what toolboxes you have available, then I'll show how to fit it.

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by