What is wrong with the code ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Opariuc Andrei
el 9 de Nov. de 2020
Respondida: Alan Stevens
el 9 de Nov. de 2020
i've got the base equations on the first 3 rows and the gauss-seidel on the last 3 rows , i tried writing a code that's like this ... and i get an error message
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/407625/image.png)
x1 + 5x2 - 6x3 = 5
3x1 + x2 + 5x3 = 23
x1 + 4x2 + x3 = 7
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/407630/image.png)
x1=(23-x2-5*x3)/3
x2=(7-x1-x3)/4
x3=(x1+5*x2-5)/6
0 comentarios
Respuesta aceptada
Alan Stevens
el 9 de Nov. de 2020
Remove the
i = i+1;
that immediately follows the while ,,, instruction.
otherwise, first time in to the loop you are trying to set x1(3) = (23 - x2(2) - 5*x3(2))/3, but you have yet to specify x2(2) and x3(2).
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!