Find values that put equation to zero
Mostrar comentarios más antiguos
In this model:
where all the variables are of dymension TX1, I need to find all the (T) values of gamma that put the equation to zero.
I tryed with the following code, but the program returns me all NAN, how can I fix the code to get it?
j=1; %increment level. The loop will work for j>1 as well.
for i=1:j:T;
fnc = @(gamma,C,S) 1./(1+gamma).*(C(i)-(S(i)*gamma)) - M(i); % Model function
rn = @(gamma) norm(M - fnc(gamma,C,S)); % Residual norm
gamma0 = [15]; % Inizializzazione
[gamma, ResNorm] = fzero(rn, gamma0);
end
Respuesta aceptada
Más respuestas (1)
Alan Stevens
el 9 de Abr. de 2021
Editada: Alan Stevens
el 9 de Abr. de 2021
If your expression is equal to zero, then you can rearrange it to get gamma directly. A little algebra gives
gamma = (C-M)./(S+M);
No need for fzero at all.
1 comentario
MARCO FORTI
el 10 de Abr. de 2021
Categorías
Más información sobre Gamma Functions en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!