|
From: | Przemek Klosowski |
Subject: | Re: Applying leasqr fit to Guassian Data |
Date: | Fri, 21 Aug 2015 17:08:38 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 |
On 08/21/2015 12:08 PM, Dan Paterson
wrote:
Welcome to Octave; I'm sure it'll be useful to you, and we'll gladly help.Hi, This is my first time on this forum, and I am uncertain that this is the right place for my question. I would like to say that my knowledge is somewhat limited as I am just finishing my undergraduate degree. I'm looking for some help on modeling that I need relating to a project I am working on for research and not for a class. I am using octave to take data from a dat file, graph the original data, model using a leasqrs fit (for a simple gaussian function), and then graph that model on the same graph. Thanks for providing everything needed to run your code, thus making it possible to retrace your steps.... You will also need the actual file you use to run it. The following is my script (I know that there are better ways to call the file, but as I had previously mentioned, my end goal is to have the whole directory): I wasn't able to fully debug this, but I had a couple of remarks---maybe they'll suffice to get you going. First of all, it looks to me like the gaussian-looking data is in the fifth column of your file, not the sixth, so you may need to data = ""> Second, your function may need an additional parameter scaling the height of the peak; you seem to be using a normalized gaussian but your data is not normalized and the easiest way to fit it is to add this normalization parameter F = @(x, p) p (1) .* exp (-(x - p (2)) .^ 2 ./ p (3)) and then you can do leasqr(t,data,[22,36,11],F) to obtain reasonable parameters: 242.46 35.866 9.8347e-02 Thirdly, as you can see, you don't need to provide every last parameter to leasqr: it can cope nicely with just the data, initial parameters and the function. |
[Prev in Thread] | Current Thread | [Next in Thread] |