Borrar filtros
Borrar filtros

need mfile for my non linear system

2 visualizaciones (últimos 30 días)
hasan s
hasan s el 24 de Dic. de 2020
Comentada: Walter Roberson el 22 de En. de 2021
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 comentarios
hasan s
hasan s el 22 de En. de 2021
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 el 22 de En. de 2021
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.

Iniciar sesión para comentar.

Respuestas (1)

Cris LaPierre
Cris LaPierre el 24 de Dic. de 2020
You can find examples and explanations about how to create a funciton file here:
  13 comentarios
Walter Roberson
Walter Roberson el 31 de Dic. de 2020
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 el 6 de En. de 2021
THANK YOU VERY MUCH

Iniciar sesión para comentar.

Categorías

Más información sobre Performance and Memory en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by