Impact-Site-Verification: dbe48ff9-4514-40fe-8cc0-70131430799e

Search This Blog

Jacobi method to solve equation using MATLAB(mfile)


% Jacobi method

 n=input('Enter number of equations, n:  ');
 A = zeros(n,n+1);
 x1 = zeros(n);
 x2 = zeros(n);
 tol = input('Enter the tolerance, tol: ');
 m = input('Enter maximum number of iterations, m:  ');

 A=[4 2 3 8; 3 -5 2 -14; -2 3 8 27];
 x1=[0 0 0];

 k = 1;
 while k <= m
   err = 0;
   for i = 1 : n
      s = 0;
      for j = 1 : n
        s = s-A(i,j)*x1(j);
      end
      s = (s+A(i,n+1))/A(i,i);
      if abs(s) > err
        err = abs(s);
      end
      x2(i) = x1(i)+s;
  end

  if err <= tol
     break;
  else
     k = k+1;
     for i = 1 : n
       x1(i) = x2(i);
     end
  end
 end

 fprintf('Solution vector after %d iterations is :\n', k-1);
 for i = 1 : n
    fprintf(' %11.8f \n', x2(i));

 end


Output:

>> jacobimethod
Enter number of equations, n:  3
Enter the tolerance, tol: 0.001
Enter maximum number of iterations, m:  100
Solution vector after 41 iterations is :
 -0.99919498 
  2.99974076 
  2.00028882 
>> 



17 comments:

  1. May I have a question, for this code, how you can plot the point x in the figure plot?

    ReplyDelete

  2. Thanks for sharing such a Excellent Blog! We are linking too this particularly great post on our site. Keep up the great writing.
    matlab assignment help

    ReplyDelete
  3. Thanks for sharing such an informative post! Those students who are looking for Referencing Help , Get the best referencing help with us, We are providing you best referencing help by our top experts who are working for you 24*7 and we will provide it at affordable price.

    ReplyDelete
  4. Essay writing help online in proficient English sometimes gets challenging for students. Therefore, they need instant essay help in English. For that, MyAssignmenthelp.com is the ultimate solution.

    ReplyDelete
  5. Essay help service to cover all essay-related topics.

    ReplyDelete
  6. Count on Hastencontracting for assistance! Our CEMENT TREATED BASE service in texas ensure that your base will survive for years without breaking or fading by utilising the best cement ingredients available. Additionally, our personnel is always available around-the-clock to respond to any of your demands in a timely and competent manner. Please contact us right away, and we'll demonstrate how we can improve Houston's safety and appearance.

    ReplyDelete
  7. The Jacobi method is a popular iterative method used to solve systems of linear equations using MATLAB. This method is known for its simplicity and ease of implementation, making it a popular choice for students and researchers. my assignment help UK provides comprehensive guidance and support to students who need assistance with solving equations using the Jacobi method in MATLAB. With their expert guidance and support, students can easily understand and implement the method to solve complex equations with ease. Overall, the Jacobi method is a reliable and efficient method for solving systems of linear equations in MATLAB.



    ReplyDelete
  8. Electra Dubai is here to assist you! On your base, we only electra cable management system dubaiuse the best cable products to ensure that it lasts for years without cracking or fading. Additionally, our personnel is always available around-the-clock to respond to any of your demands in a timely and competent manner. Please get in touch with us right away, and we'll demonstrate how we can improve the visual appeal of your offerings.

    ReplyDelete
  9. The actress Jenna Ortega is stunning, and she has incredible style. Because her followers admired the way she dressed and looked, this Scream 6 Jenna Ortega Jacket quickly reached the top of the winter fashion list.

    ReplyDelete
  10. Online quiz help services in Australia are designed to assist students who require additional support with their quizzes. These services offer a range of options to cater to the specific needs of individual students. Online quiz help can include anything from providing study materials and practice quizzes to one-on-one tutoring sessions with experienced tutors.

    Students may use Online Quiz Help services for a variety of reasons. For example, they may find it difficult to manage their time effectively, struggle with certain topics, or simply need extra help to achieve their desired grade. Online quiz help can be especially beneficial for students who are studying remotely or who are unable to attend traditional tutoring sessions due to time or location constraints.
    we are also provide the Assignment Help Onlineservice in australia

    ReplyDelete
  11. Excellent article. Because you make everything clear and easy to understand, I like the way you write. Beth Dutton Blue Poncho

    ReplyDelete
  12. Thanks for your article, it's clear and easy to understand, I like the way you write. I've always used catchmod to download useful tech apps for both work and play. With Mod APK catchmod, finding and installing applications is easier and more convenient than ever. Thanks to these apps, I can be more productive, do word processing, graphic design and project management professionally. Mod APK catchmod provides a diverse and rich application store. I often download apps like Netflix, Spotify and Kindle to enjoy movies, listen to music and read books on my mobile phone. In addition, I also download gaming apps like PUBG Mobile or Among Us to entertain in my free time.

    ReplyDelete
  13. Unlock amazing discounts on fashion, electronics, travel, and more at Wayfair Discount Code the home of great deals.

    ReplyDelete
  14. Welcome! I'm a beauty expert dedicated to educating and empowering others through beauty. Join me on S 4 She to explore the transformative power of makeup and skincare.

    ReplyDelete
  15. Learning MATLAB's Jacobi method is a step towards efficient equation solving. While diving into exploration, ensure you have the best Exploration catering services in Houston Texas to fuel your endeavors.

    ReplyDelete
  16. Using the Jacobi method to solve equations in MATLAB is a powerful approach, just like finding an affordable Cheap Car Wash Near Me Ottawa. Both ensure efficient solutions – one for mathematical problems and the other for keeping your car in top shape without breaking the bank. Smart choices all around!

    ReplyDelete