From: Matt Fig on
You don't say what the problem is, but one thing I spot right away is that you are trying to index x with 0. MATLAB arrays do not have a 0 index, they start at 1.