New users and old of optimization in MATLAB will find useful tips and tricks in this document, as well as examples one can use as templates for their own problems.
Use this tool by editing the file optimtips.m, then execute blocks of code in cell mode from the editor, or best, publish the file to HTML. Copy and paste also works of course.
Some readers may find this tool valuable if only for the function pleas - a...
(This function was suggested to me as a counterpart to the uigetvar function.)
The putvar tool allows you to assign a variable from a function workspace directly into the base workspace. I can envision this tool having value in one of...
Often I see students asking for help on a tool to compute the Fibonacci numbers. Or, I'll find them asking for help on a Project Euler problem. Or, a student has been assigned the problem of computing the fibonacci numbers using a recursive...
Did you ever want the ability to define a special constant that is seen by and used in all of your functions, without needing to create global variables?
For example, suppose you used the golden ratio often in your work. Rather than...
Some curve fitting or smoothing tools can benefit from knowledge of the noise variance to expect on your data. Kalman filters use this information, also some spline fitting tools. So I wrote a function to extract the noise variance from a signal...
I am occasionally asked for a 3-d version of my useful inpaint_nans tool. This does it, although I only included the most commonly used methods from inpaint_nans.
I need to thank Duane Hanselman for suggesting this great idea.
Fminspleas is a simple nonlinear least squares tool that fits regression models of the form
Y = a1*f1(X,C) + a2*f2(X,C) + ... + an*fn(X,C)
X can be...
Occasionally I see a request for computation of a running, windowed standard deviation. This is easily accomplished using filter and the alternative formula for the standard deviation:
std = sqrt((sum(x.^2) - n*xbar.^2)/(n-1)).
Some optimization problems have very simple surfaces to optimize. The optimizer simply proceeds downhill to the unique minimizer and returns happily - all is good in the world. Sadly, more often the objective function has multiple local...
Nonlinear optimization problems with bound constraints can be solved using FMINSEARCHBND (as well as using many other tools.) For the user who has a problem with linear inequality constraints and/or general nonlinear inequalities as well as bound... |