How do I fit a sinusoidal curve to data? Trouble with fitit

1 次查看(过去 30 天)
Hello, I am new to Matlab and am working on a final project for school. I would like some assistance with figuring out what to do with a data set. I basically modeled certain fashion trends over time and assigned a certain fashion trend with values ranging from 1 to 5.
Here's my time (x axis) vector: t=1900:5:1995;
Here's my y-data vector: shoulders = [5 4 3 2 2 1 3 4 5 5 4 3 3 1 2 2 5 5 5 3];
I feel like the data oscillates and I would like a sinusoidal function to fit my data points, how do I do this? I tried googling it and found a function called fitit that a user made, but when I tried to run it, it says that my X value didn't match up with my rows. I don't quite fully understand the whole program, so I would like some help in understanding where in the program I change the number of rows it requires to just 1.
Since I only have 20 data points, if that is not enough data points for fitit to work well, what other functions can I use to fit my sinusoidal functions? Sorry, I'm just not super comfortable with curve fitting oscillations and would like as much help as possible :)

回答(1 个)

sixwwwwww
sixwwwwww 2013-12-7
编辑:sixwwwwww 2013-12-7
you can try curve fitting tool for this purpose. See
doc cftool
And you can try different kind of curve fittings by yourself to find out which suits your purpose well

类别

Help CenterFile 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!

Translated by