Loop structure for fixed point.
Mostrar comentarios más antiguos
Hello, I have problem with Loop structure for fixed point.

This is the problem, and i made code like this.

It only caculates 1 time and just stops. Which mean, it's not repeating my code, xb=x; and x=sqrt(1.8*x+2.5)
if i manually repeat xb=x; and x=sqrt(1.8*x+2.5) the answer is correct, however it's not repeating those code.
What's wrong about my loop and How to fix it?
5 comentarios
Rik
el 16 de Abr. de 2021
Please post your code as code. Also, why haven't you tried stepping through your code line by line to see what the variables are?
You can find guidelines for posting homework on this forum here. If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks). If your main issue is with understanding the underlying concept, you may consider re-reading the material you teacher provided and ask them for further clarification.
I hope @VBBV will not actually do as you ask and provide a working solution. If you hand that in as your own work you would be commiting academic fraud. Asking for help is fine, asking for solutions isn't.
Your question is asking for help, the comment you wrote was asking for a solution. I was not claiming you were doing something nefarious, I was simply pointing you to helpful guidelines and to a tutorial.
If you had actually stepped through your code, you would have realised the values of your variables:
x0=5;
x=sqrt(1.8*x0+2.5);
xb=x;
x=sqrt(1.8*x+2.5);
disp((x-xb)/x)
The solution to your problem is that you probably want to look at the absolute value of the error term.
Rik
el 17 de Abr. de 2021
How large is that difference? And what is the code you're currently using? And what results are you expecting?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!