![]() If we are working on calculating the first variable, then we don't have any new information yet, and so we simply just update the solution using all of the previous information from the previous iteration. If idx = 1 %// Case where we are solving for the first variable Therefore: function z=gaussseidel(A,B) %// Change the function name This has to be done in the while loop, because that's where you're doing the iterations. For Gauss-Seidel, for each variable that you solve for, you must use the solutions of the previous variables calculated from the current iteration as part of the solution for the variable you are focusing on.Īs such, for your particular version of the code (though not optimal.), you simply need to add in a for loop where we solve for each variable one at a time, then keep feeding this information into the other variables. For Jacobi, you are simply using the previous iteration's solution to formulate the current solution. , x_) as part of the solution for the current variable x_i. ![]() The difference between a Jacobi solver and a Gauss-Seidel solver is that when you're solving for the solution of a variable x_i at the current iteration, you need to use the information from the previous variables ( x_1, x_2. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |