필터 지우기
필터 지우기

need mfile for my non linear system

조회 수: 2 (최근 30일)
hasan s
hasan s 2020년 12월 24일
댓글: Walter Roberson 2021년 1월 22일
I have to employ the newton raphson algorithm to solve my equations,. I need to create a function m-file to do so. This is my first matlab assignment and I'm not really familiar with it. I don't really know how to go about the iteration and I try to write it but matlab not solve. this is my try. Any help would be greatly appreciated.
  댓글 수: 4
hasan s
hasan s 2021년 1월 22일
It has been discovered that the question I asked contains errors
The program has been canceled due to a mistake in the question
I deleted it so as not to affect the followers because my question is wrong
Your valuable suggestions remain.
Thanks for your efforts
Walter Roberson
Walter Roberson 2021년 1월 22일
However, our solution is for the question as posted, and is useful for people who might want to study the techniques.
It is not uncommon for people to discover that they made a mistake in asking the question when they start thinking about the responses they got. It is also not uncommon that when users see how the volunteers interpret the question that was actually asked, that the user's thought processes are pulled out of the grove they were in, and are able to see how they should have proceeded. Thus, even questions containing mistakes are valuable to readers. Indeed, most questions that are posted contain a mistake of some sort, and figuring out what the mistake is is a lot of what we do here.

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

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 12월 24일
You can find examples and explanations about how to create a funciton file here:
  댓글 수: 13
Walter Roberson
Walter Roberson 2020년 12월 31일
I did not write gamma "instead" of anything. Your code had
x=[B(i)+G(i)*(gamma(1+1/A(i)))-sum1;(G(i)^2)*(gamma(1+2/A(i)))
+(2*B(i)*G(i)*gamma(1+1/A(i))
+B(i)^2-sum2);(G(i)^3*gamma(1+3/A(i))+3*B(i)*G(i)^2*gamma(1+2/A(i))+3*G(i)*B(i)^2*gamma(1+1/A(i))+B(i)^3-sum3)];
which already has gamma in it. I reformatted,
x=[B(i)+G(i)*(gamma(1+1/A(i)))-sum1;
(G(i)^2)*(gamma(1+2/A(i)))+(2*B(i)*G(i)*gamma(1+1/A(i))+B(i)^2-sum2);
(G(i)^3*gamma(1+3/A(i))+3*B(i)*G(i)^2*gamma(1+2/A(i))+3*G(i)*B(i)^2*gamma(1+1/A(i))+B(i)^3-sum3)];
which is just moving around the line breaks.
q=inv(d);
p=q*x;
cannot be replaced by x/d but can be replaced by
p=d\x;
No,
A(i+1)=z;
B(i+1)=z;
G(i+1)=z;
is not a replacement for the existing lines. z is a vector of length 3, but A(i+1) only designates a single output location. You also want A, B, and G to get different outputs, but assigning z to all of them would give the same value to each.
What you could do is
zcell = num2cell(z(1:3));
[A(i+1), B(i+1), G(i+1)] = zcell{:};
but this is less clear than just doing three assignment statements.
T=1;
A=2;
B=3;
G=4;
That will not work. You have
for j=1:50
sum1=sum1+log((T(j)-B(i))/G(i));
When j becomes 2, you need to access T(2) but T has only been initialized as a scalar. You never store into T after the initial assignment.
hasan s
hasan s 2021년 1월 6일
THANK YOU VERY MUCH

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

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by