Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have been fiddeling around with matlab for a bit now, and i think it's an amazing program. I am not very strong with it, but i was wondering if there is any way to calculate a sine regression to fit given data.
I have been able to graph the data using [CODEplot(time,hight,'*')][/CODE]
I am trying to fit a sine regression / best fit line to fit the data.
Does anybody here know how to do something like this?
Matlab's help mentions multiple regression and fitting functions, but none seem to include "sine regression" (at first sight). Altough that may be included in toolboxes that I don't have installed.
Perhaps there are some alternative functions you can try at Matlab Central's file exchange: http://www.mathworks.com/matlabcentr...oadCategory.do
in the Mathematics category probably.
Those functions may still be a little buggy though.
I have two lists (variables), one containing the x-values, an other one containing the y-values. I have not yet found a way of actually calculating a sine wave which fits these (less than 30) values.
The format for the wave should be something like this "y=a*sin(b*x+c)+c".
Is there any paractical way (without having to get a degree in advanced mathematics first) to calculate something like this??
I don't really know how the TI 83 works, so can't help you with that. It may just plot a sine that approximates the given values (not really fitting it as good as possible).
"fitting" (ie least square fitting) is usually an iterative approach. That always involves making slight changes to the variables in a function (such as a sine function) until some error value is minimized.
In your case, the error value could be something like the RMS value of distance between each value and the sine wave. Based on that RMS error indication, you can slowly adjust your sine parameters until the RMS reaches a minimum. Matlab surely has functions for that. Check out least squares fitting, for instance.
Another approach would be to just make a sinusoid that approaches your values, rather than actually "fitting" as closely as possible.
To do this, you simply need to determine 3 things: the sine's amplitude and frequency (or wavelength) and the phase.
In general, a sinusoid is something of the form:
y = A * sin(bx + c)
"A" is your amplitude, "b" is related to the frequency (or 1/wavelenght) in the x direction and "c" is the phase (in radians).
If you plot the values, you should be able to approximate each of the values.
You could also use these values as starting point for the least square fitting.
I don't really get why you included yet another "+c" in your formula for sinusoids (ie "sine-like function").
The +c you've added would probably only be an offset in the y direction (ie if the mean value of your wave isn't at y=0 but at y=c). This "y offset" is however unrelated to the sine's phase, so -mathematically speaking- you should call them "c1" and "c2" instead of just 2 times "c".
I am not sure how i could have ever made that typo.
I think i got the concept now: one has to specify the starting values for each variable. I though that matlab would simply calculate a best fitting line, without any start-data given.
No. I believe there is no such thing like "fitting without starting data".
You normally need to have starting data, provided from an approximation, a best guess, etc.
Fitting is typically an iterative approach, starting with some data, that adjust the variables slightly (in each iteration), until some error value is minimized.
The downsides of such an iterative algorithm are
1. performance
2. they can get stuck on "local minima". Let's say that the error is decreasing, reaches a local minimum and then increases slightly before going down again to the real minimum. The iterative algo may stop at the local minimum instead of pursuing the real one. Their are alternative approaches, such as neural networks, to get past this disadvantage.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.