lsqlin giving a solution that is within constraints but far away from target vector
4 ビュー (過去 30 日間)
古いコメントを表示
I have a vector with values d, they are equidistantly spaced. I want to find a vector of values close to d but with a positive second derivative and on the left boundary the first derivative
and on the right boundary the first derivative
. Therfore I wanted to use central difference to create the constraints and then use lsqlin. With this snippet of code to explain the issue:
d = [753.075 557.679 376.430 223.481 143.982 93.779 91.431 92.757]';
C = eye(size(d,1));
A = (-diag(ones(size(d,1)-1,1),-1)-diag(ones(size(d,1)-1,1),1)+2*diag(ones(size(d,1),1)))./50;
A(1,1) = 1/50;
A(end,end-1) = -1;
A(end,end)=1;
b = [exp(-0.159),zeros(1,size(d,1)-1)];
correctd = lsqlin(C,d,A,b);
figure
hold on
plot(1:8,correctd)
plot(1:8,d,'o')
hold off
This results in the following plot:

The code claims it found a minimum that satisfies the constraints. "Optimization completed because the objective function is non-dectreasing in feasibel directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance."
I tried to find out what the default constraints are, and they should have been much lower than the sum of squares of around 176 thousand that I am getting. I have done this too with other values for the vector d with similar results. What should I change or do to resolve this problem?
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Linear Least Squares についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!