Having trouble with array dimensions in an arrayfun call with fminsearch nested in it
Show older comments
Hey all,
I've been working on a multivariable nonlinear regression problem, and ran into some trouble in the regression part of it. The code is as follows:
options = optimset('MaxFunEvals',10,'MaxIter',8);
c0 = zeros(100,1);
c_hat = arrayfun(@(a,b) fminsearch(@(c) 1/2*(a(1,1:2)*a(1,1:2)'-(b*c)*(b*c)')+lambda*sum(c),100,options),y,Phi);
Here are some notes I have about the issue.
- size(y) = size(a) = 2x100
- size(Phi) = size(b) = 2x100
- y is originally 2x1 but has been padded with 0's for the sake of accomodating parameter requirements for arrayfun
- Can't index into a using a(1,1:2) because a has not been defined yet, but I need to pad the a in order to use arrayfun. Catch22
- want size(b*c) = 2x1, and accordingly, size(c) = 1x100. The returned coefficients as a result of minimization, c_hat, would therefore 1x100, as I'd want it to be.
How do I address this? Thanks in advance!
Accepted Answer
More Answers (0)
Categories
Find more on Gaussian Process Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!