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

조회 수: 2 (최근 30일)
Magnus
Magnus 2014년 11월 21일
편집: Matt J 2014년 11월 21일
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

채택된 답변

Matt J
Matt J 2014년 11월 21일
편집: Matt J 2014년 11월 21일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by