MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
Asked by Angelina on 3 Dec 2012

Hey. I asked a question yesterday about this script, but I found out how to make it run. Now my problem is, that I only get 1 solution to my system, and I need two solution. The following equations are my system:

2u^2 - 4u + v^2 + 3w^2 + 6w + 2 = 0

u^2 + v^2 - 2v + 2w^2 - 5 = 0

3u^2 - 12u + v^2 + 3w^2 + 8 = 0

Matlab puts following output:

u= 4,6293

v= -2,0049

w= -1,0295

and I need to get:

u = 1,096 and u=2

v = -1,1592 and v= 1

w=-0,26115 and w = -1

This is my script:

% Computer problem % x0 startgÃ¦t, k antal iterationer % kald fx. NEWTm([1;1;1],2)

function x=NEWTm(x0,k)

x=x0;

for i=1:k

b=F(x);

s=DF(x)\b;

x=x-s;

end;

end

function y=F(x)

y=zeros(3,1); % 0-punkter i 3x1 matrix

y(1)=2*x(1)^2 - 4*x(1) + x(2)^2 + 3*x(3)^2 + 6*x(3) + 2;

y(2)=x(1)^2 + x(2)^2 - 2*x(2) + 2*x(3)^2 - 5;

y(3)=3*x(1)^2 - 12*x(1) + x(2)^2 + 3*x(3)^2 + 8;

end

function dy=DF(x)

dy=zeros(3,1);

dy(1,1)=4*x(1)-4;

dy(1,2)=2*x(2);

dy(1,3)=6*x(3)+6;

dy(2,1)=2*x(1);

dy(2,2)=2*x(2)-2;

dy(2,3)=4*x(3);

dy(3,3)=6*x(1)-12;

dy(3,2)=2*x(2);

dy(3,3)=6*x(3);

end

Hope anyone can help me.

*No products are associated with this question.*

Answer by Walter Roberson on 3 Dec 2012

You will need to use a different starting point to find the second solution.

## 0 Comments