Numerical Recipes Forum  

Go Back   Numerical Recipes Forum > Numerical Recipes Third Edition Forum > Using NR3 with MATLAB

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-01-2008, 02:33 PM
William Handler William Handler is offline
Registered User
 
Join Date: Jul 2008
Location: London Ontario
Posts: 16
wrapper for the simplex fitter amoeba

Hello,

I wrote a mexfunction to run the NR simplex fitter amoeba which anyone is welcome to use, I would also appreciate any comments on how I did it, or how it may be improved.

The mexfunction is in NRFitSimplex.cpp

The mexfunction uses a class FitFunction, which is a functor that calls a user defined, in the matlab space, function. This means that it is a general fitter and can be used to fit data with any user defined function of choice. The function that amoeba actually minimizes is the chi squared function for the data and the fit function.

I added a further wrapper in matlab, FitSimplex.m to do a plot of the fit, a picture being worth a thousand words.

I tested the code using a Gaussian function and it works quite nicely giving good fits. The only thing I have not figured out yet is how to extract the errors on the fit parameters.

Overall it acts like it should, I now have a fairly simple function I can call from the matlab environment to fit data with. I am using this example as a basis for further matab wrappers to numerical recipes code, so any things I could do better let me know.

I am including all the relevant files in attachments hopefully.

Looking forward to some feedback,

Will
Attached Files
File Type: zip temp.zip (5.5 KB, 18 views)
Reply With Quote
  #2  
Old 11-11-2008, 02:55 AM
orstats orstats is offline
Registered User
 
Join Date: Nov 2008
Posts: 12
Examples of Running NR in MATLAB

Hello:

Are there simpler examples of using NR libraries in MATLAB environment after 'introducing MATLAB to your compiler'? The tricky part is feeding the function parameters back and forth between MATLAB functions and NR functions... Thanks in advance!
Reply With Quote
  #3  
Old 11-21-2008, 12:47 PM
William Handler William Handler is offline
Registered User
 
Join Date: Jul 2008
Location: London Ontario
Posts: 16
The only tricky part

That's pretty much the whole thing. After all, calling the numerical recipes routines in a piece of c code is very straightforward. The whole problem is one of passing the information back and forth between matlab and your c code. I am going to post an example of some of the numerical integration techniques that might help.

By the way, sorry for the delayed response, I did not recieve any email telling me that you had posted.

Will Handler
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:12 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.