• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# matlab

a guest Mar 23rd, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. %solving the equations using Gauss-Seudek method :
2. %5x1+2x2-x3-x4=0
3. %2x1+9x2+x3-x4=4
4. %x1-2x2+1-x3+x4=5
5. %x1+x2+x3+6x4=30
6. %initial values:x2=0,x3=0,x4=0
7. %iterate 3 times
8. %solution:
9. %x1=(x4+x3-2x2)5
10. %x2=(4+x4-x3-2x1)9
11. %x3=(5-x4+2x2-x1)10
12. %x4=(30-x3-x2-x1)6
13. clear;csc;format('long','g');
14. i=1;
15. x2(i)=0;
16. x3(i)=0;
17. x4(i)=0;
18. iterats(i)=4;
19. while iterats(i)<=4
20.     disp(iterate (i));
21.     x1(i+1)=(x4(i)+x3(i)-2*x2(i))/5;
22.     x2(i+1)=(4+x4(i)-x3(i)-2*x1(i+1))/9;
23.     x3(i+1)=(5-x4(i)+2*x2(i+2)-x1(i+1))/10;
24.     x4(i+1)=(30-x3(i+3)-x2(i+1)-x1(i+1))/6;
25. end
26.
27. disp('x1');
28. disp('x2');
29. disp('x3');
30. disp('x4');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top