asdsds

475 views

Published on

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
475
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

asdsds

  1. 1. FUNCION GAUSS EN MATLAB CÓDIGO function x= gauss01(A,b) n = length(b); for k = 1:1:(n-1) for i = k+1:n m= A(i,k)/A(k,k); A(i,k)=0 A(i,k+1:n) = A(i,k+1:n) - m*A(k,k+1:n); b(i)= b(i) - m*b(k); end end x=zeros(n,1); x(n)=b(n)/A(n,n); for k=n-1:-1:1 x(k)=b(k); for j=k+1:n x(k)=x(k)-A(k,j)*x(j); end x(k)=x(k)/A(k,k); end disp('Solucion del sistema AX=B'); COMPROBACIÓN >> A=[4 0 2 -3;3 -2 2 -3;2 4 -1 1;-1 1 1 -1] A= 4 0 2 -3 3 -2 2 -3 2 4 -1 1 -1 1 1 -1
  2. 2. >> b=[-9 14 9 -4] b= -9 14 9 -4 >> gauss01(A,b) A= 4 0 2 -3 0 -2 2 -3 2 4 -1 1 -1 1 1 -1 A= 4.0000 0 2.0000 -3.0000 0 -2.0000 0.5000 -0.7500 0 4.0000 -1.0000 1.0000 -1.0000 1.0000 1.0000 -1.0000
  3. 3. A= 4.0000 0 2.0000 -3.0000 0 -2.0000 0.5000 -0.7500 0 4.0000 -2.0000 2.5000 0 1.0000 1.0000 -1.0000 A= 4.0000 0 2.0000 -3.0000 0 -2.0000 0.5000 -0.7500 0 0 -2.0000 2.5000 0 1.0000 1.5000 -1.7500 A= 4.0000 0 2.0000 -3.0000 0 -2.0000 0.5000 -0.7500 0 0 -1.0000 1.0000 0 0 1.5000 -1.7500
  4. 4. A= 4.0000 0 2.0000 -3.0000 0 -2.0000 0.5000 -0.7500 0 0 -1.0000 1.0000 0 0 0 -2.1250 Solucion del sistema AX=B ans = -41.6667 9.3333 -322.6667 -267.6667 >>

×