我在更大的脚本中使用fsolve
。 fsolve
返回No solution found
。我试图在for循环中找到矩阵的行,这些行遵循某些限制。这对我以前的行optimoptions('fsolve', 'Algorithm', 'levenberg-marquardt')
有所帮助。现在,我被卡住了,因为我不知道哪些其他选项有意义。如果不了解它们,我没有运气尝试不同的选择。
这是返回的代码 No solution found
options1 = optimoptions('fsolve', 'Algorithm', 'levenberg-marquardt');
[gamma_k_1y, fval, exitflag, ~] = fsolve(@(gamma_k_1y) f_gamma( gamma_k_1y, m, bstar(k), Lstar, min(y,m) ), zeros(min(y,m),1), options1);
这是我想要解决的功能
function F = f_gamma( gamma_1y, m, bstar_k, Lstar, y )
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
F(1) = sum( gamma_1y ); % row sum zero
F(2) = sum( gamma_1y.^2 ) - m; % elements squared = m
F(3) = sum( (Lstar(1,1:y).^2) * gamma_1y) - m * bstar_k; % first row squared times new row = m times element od bstar
n_assigned_rows = sum(~isnan(Lstar(:,1)));
for i=1:n_assigned_rows
F(i+3) = Lstar(i,1:y) * gamma_1y; %element wise multiplication with each row except self zero
end
end
这些是我的变量
% -------------------------------------------------------------------
% Generated by MATLAB on 18-Jul-2017 11:17:31
% MATLAB version: 9.2.0.538062 (R2017a)
% -------------------------------------------------------------------
Lstar = ...
[1.9193221763392923 -1.8182365289779376 -0.10108564736135461 0 0 0 0;
-0.054995957568300745 0.045658192660796168 -1.8654711092538141 1.8748088741613205 ...
0 0 0;
-0.045613771137015049 0.011357535373129623 -1.0703617279866948 -1.0666452698891478 ...
2.1712632336401225 0 0;
-0.010566489657722691 -0.0548196464049537 0.78541897633795066 0.78253217221128113 ...
0.77167395707940156 -2.2742389695659573 0;
-0.024717877486905307 -0.059891167589263682 0.60794721966412446 0.60565273026541278 ...
0.59702240468188983 0.62248826258542045 -2.348501572120679;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN NaN NaN];
alpha = [1.9193221763392923 -1.8182365289779376 -0.10108564736135461 0 ...
0 0 0];
b = [1; 1; 1; 1; 2; 1; 1];
beta = [-0.054995957568300745 0.045658192660796168 -1.8654711092538141 ...
1.8748088741613205 0 0 0];
beta_14 = [-0.054995957568300745; 0.045658192660796168; -1.8654711092538141; ...
1.8748088741613205];
bstar = [0.15118578920369091; -0.010101525445522112; -0.020203050891044225; ...
-0.030304576336566323; -0.040406101782088436; 0.020203050891044225; ...
0.010101525445522112];
exitflag = -2;
fval = [-4.2566077443698074 -2.221444134718805 1.5553705289078517 -0.64353855088729561 ...
0.042998187795194528 0.085996469204826287 0.12899460131301721 0.17199288121327205 ...
];
gamma_k_1y = [0.050858405964284731; 0.45946005395777284; -0.93242551108612626; ...
-0.91454430220858973; -0.8706585765149597; -1.0001539165810418; ...
-1.0491438979011476];
gamma_k_ym = saveVarsMat.gamma_k_ym; % <1x0 double> empty object
j = 7;
k = 6;
m = 7;
n = 20;
omega = ...
[0.3779644730092272 0.70710678118654746 0 0 0 0 0;
0.3779644730092272 -0.70710678118654746 0.70710678118654746 0 0 0 0;
0.3779644730092272 0 -0.70710678118654746 0.70710678118654746 0 0 0;
0.3779644730092272 0 0 -0.70710678118654746 0.70710678118654746 0 0;
0.3779644730092272 0 0 0 -0.70710678118654746 0.70710678118654746 0;
0.3779644730092272 0 0 0 0 -0.70710678118654746 0.70710678118654746;
0.3779644730092272 0 0 0 0 0 -0.70710678118654746];
x = 1.9193221763392923;
y = 8;
z = -0.10108564736135461;
我知道有一个解决方案,因为R可以在nleqslev
指定选项allowSingular=TRUE
时解决此问题。
答案 0 :(得分:0)