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

1 visualización (últimos 30 días)
Magnus
Magnus el 21 de Nov. de 2014
Editada: Matt J el 21 de Nov. de 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

Respuesta aceptada

Matt J
Matt J el 21 de Nov. de 2014
Editada: Matt J el 21 de Nov. de 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

Más respuestas (0)

Categorías

Más información sobre Systems of Nonlinear Equations en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by