solving equation returns vector. Sum of vector=0. How?

1 vue (au cours des 30 derniers jours)
Magnus
Magnus le 21 Nov 2014
Modifié(e) : Matt J le 21 Nov 2014
Dear all,
I attempt to solve an optimisation problem. I want to solve the equation...
function [funzeta1] = Fz1(zzeta1)
funzeta1=-Ub.*zzeta1+cos((pi.*xint.*2.0)/v(1)).*(v(3).*(exp((pi.*zzeta1.*-2.0)/v(1))+exp((pi.*zzeta1.*2.0)/v(1))).*(1.0/2.0)-v(2).*(exp((pi.*zzeta1.*-2.0)/v(1))-exp((pi.*zzeta1.*2.0)/v(1))).*(1.0/2.0))+((Ub-Ui1).*(d.*zzeta1+zzeta1.^2.*(1.0/2.0)))/(d-di1)+(v(1).*zzeta1)/T-Psi1;
end
...using fsolve to determine zzeta1. As xint is a vector, zzeta1 is a vector as well, which is desired! However, C1=sum(zzeta1) shall be zero and I need zzeta1 for further computations. I had both funcitons, funzeta1 and C1 in one function and C1 returned, but I can't return both values, as C1 is a scalar and zzeta1 is a vector, so I obviously would get the error message that both can't be concatenated
How do I do it?
Any help is very appreciated.
Kind regards

Réponse acceptée

Matt J
Matt J le 21 Nov 2014
Modifié(e) : Matt J le 21 Nov 2014
Isn't it just a matter of adding an additional equation?
function [funzeta1] = Fz1(zzeta1)
funzeta1=-Ub.*zzeta1+cos((pi.*xint.*2.0)/v(1)).*(v(3).*(exp((pi.*zzeta1.*-2.0)/v(1))+exp((pi.*zzeta1.*2.0)/v(1))).*(1.0/2.0)-v(2).*(exp((pi.*zzeta1.*-2.0)/v(1))-exp((pi.*zzeta1.*2.0)/v(1))).*(1.0/2.0))+((Ub-Ui1).*(d.*zzeta1+zzeta1.^2.*(1.0/2.0)))/(d-di1)+(v(1).*zzeta1)/T-Psi1;
funzeta1=[funzeta(:);sum(zzeta1)]; %additional equation
end

Plus de réponses (0)

Catégories

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

Community Treasure Hunt

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

Start Hunting!

Translated by