What am I missing in this code I am trying to find roots of a System of Equation?

조회 수: 1 (최근 30일)
I am trying to find values of θ and γ for a system of equation where x(1)=θ and x(2)=γ in the code.
The equations are;
I am using the code below but I couldn't find the correct answer. The answer for
The code works, but I get different values for different x intervals, and none of them are correct. (In this case 97.90)
What am I missing?
a(1,1) is the partial differential of with respect to θ
a(1,2) is the partial differential of with respect to γ
a(2,1) is the partial differential of with respect to θ
a(2,2) is the partial differential of with respect to γ
b(1) is
b(2) is
clc;clear;
x=[-1 0.8]; err=[0.01 0.01];
niter1=10;
niter2=50;
err=transpose(abs(err));
for n=1:niter2
x
%Error Equations---------------------------
a(1,1)=-0.2*sin(x(1))+0.2*((1-0.25*sin(x(1))^2)^(-1/2))*(-0.5*sin(x(1))*cos(x(1))); a(1,2)=0;
a(2,1)=0.2*cos(x(1)); a(2,2)=-0.4*cos(x(2));
b(1)=0.2*cos(x(1))+0.4*sqrt(1-0.25*sin(x(1))*sin(x(1)))-0.32;
b(2)=0.2*sin(x(1))-0.4*sin(x(2));
%----------------------------------------------
bb=transpose(b);eps=inv(a)*bb;x=x+transpose(eps);
if n>niter1
if abs(eps)<err
break
else
disp ('Roots are not found')
end
end
end

채택된 답변

Walter Roberson
Walter Roberson 2020년 5월 26일
x=x+transpose(eps)
That should be subtraction rather than addition.
  댓글 수: 1
Ömer Faruk AKSOY
Ömer Faruk AKSOY 2020년 5월 26일
First I want to thank you for the answer it worked fine and I find the correct answer. But can I ask why it should be substruction? I have solved many problems doing addition and they worked well and I find the correct answer.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by