Hi, currently I trying to solve for a system of nonlinear equations (5 equatios in total).
Here is my function part
% Coeffecient
M1 = 0.5;M2 = 0.75;M3 = 0.95;M4 = 1.102;M5 = 1.102;K = 1;Kc = 1;Kk = 3;KR = 0.95;G = 0.001; GR = 0.1;Gc = 0.005;B = 0.15;A= 1;w= 1:0.1:2;%Set up equation
function F = MyFunction(x) F(1 )= x(1).*(-M1.*(w.^2) + K + Kc +KR + G.*1i.*w) - (A.*(exp(1i.*w)) + Kc.*x(4) + KR.*x(3)); F(2) = x(2).*(-M2.*(w.^2) + K + Kc +KR + G.*1i.*w) - (A.*(exp(1i.*w)) + Kc.*x(5) + KR.*x(3)); F(3) = x(3).*(-M3.*(w.^2) + 2.*kk + GR.*1i.*w) - (KR.*(x(1) + (x(2)))); F(4) = x(4).*(-M4.*(w.^2) + Kc + kk + Gc.*1i.*w) - B.*1i.*(w.^3).*((x(4)).^3) - A.*(exp(1i.*w)) - Kc.*x(1); F(5) = x(5).*(-M5.*(w.^2) + Kc + kk + Gc.*1i.*w) - B.*1i.*(w.^3).*((x(4)).^3) - A.*(exp(1i.*w)) - Kc.*x(2); end
Then I create a different file to call back to it
x0 = [1 1 1 1 1];x = fsolve(@MyFunction,x0);
So the idea is to solve x1, x2, x3, x4, x5 as a function of w. But I have tried fixing w to 1 value, as well as move the coeffecient to the 2nd file. But I still could fix this message that MATLAB gave me " Failure in initial objective function evaluation. FSOLVE cannot continue"
Anybody have a way for me to fix this
Best Answer