Effacer les filtres
Effacer les filtres

How do I input a time dependent variable from one function to fsolve function equations?

2 vues (au cours des 30 derniers jours)
function F = A_U_G(x)
a = 2360000000;
b = 1610000000;
c = 700000;
d = 4640000000;
F(1) = x(1) - (u/b) + (b*x(2)); % qAmm
F(2) = x(2) - ((u/c)*(c/(c + d))); % qUrd
F(3) = x(3) - (u/Yd) - (x(1)*t); % qGln
end
Above is the fsolve function
x0 = [0,0,0];
x = fsolve('A_U_G',x0);
qA = x(1);
qU = x(2);
qG = x(3);
Above is the call
Now in the same function where call is made for fsolve function lies variable u, t that changes with time after each iteration.
And I want them to also change their values in function F. So, what changes need to be done?

Réponse acceptée

Walter Roberson
Walter Roberson le 3 Juin 2021
u = randn();
x0 = [0,0,0];
x = fsolve( @(x) A_U_G(x,u), x0);
Unrecognized function or variable 'Yd'.

Error in solution>A_U_G (line 16)
F(3) = x(3) - (u/Yd) - (x(1)*t); % qGln

Error in solution (line 4)
x = fsolve( @(x) A_U_G(x,u), x0);

Error in fsolve (line 260)
fuser = feval(funfcn{3},x,varargin{:});

Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
qA = x(1);
qU = x(2);
qG = x(3);
function F = A_U_G(x, u)
a = 2360000000;
b = 1610000000;
c = 700000;
d = 4640000000;
F(1) = x(1) - (u/b) + (b*x(2)); % qAmm
F(2) = x(2) - ((u/c)*(c/(c + d))); % qUrd
F(3) = x(3) - (u/Yd) - (x(1)*t); % qGln
end

Plus de réponses (0)

Catégories

En savoir plus sur Systems of Nonlinear Equations dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by