I HAVE A BIG PROBLEM :(
Afficher commentaires plus anciens
IN THIS
clc
clear
disp('------------------Eliminacion Gaussiana------------------');
A=input('Matriz de incognitas (matriz cuadrada):');
[fila columna]=size(A);
for j=1:columna;
for i=j+1:fila;
Piv1=-A(i,j)
for k=j:columna;
A(i,k)=Piv1*A(j,k)+A(j,j)*A(i,k)
end
end
end
%sustitución regresiva
for j=columna:-1:1
sum=0;
for i=j+1:1:columna;
sum=sum+A(j,i)*X(i,1);
end
if A(j,j)~=0;
X(j,1)=(A(j,columna+1)-sum)/A(j,j);
else
disp('División cero')
end
end
disp (X)
WITH THIS
[3 5 4 7 10;2 5 3 -2 8; -4 0 -2 1 4; -1 -3 5 2 6]
HAVE A ERROR LIKE:
Attempted to access A(5,5); index out of bounds because size(A)=[4,5].
Error in Untitled2 (line 22)
if A(j,j)~=0;
Réponses (2)
Walter Roberson
le 6 Sep 2015
for j = 1 : columna - 1
You appear to be representing a 4 x 4 system with a 1 x 4 column of results, as a 4 x 5 matrix. You should only be trying to pivot the 4 x 4 matrix, not the whole 4 x 5 matrix.
Olivia Hernandez
le 6 Sep 2015
0 votes
Catégories
En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!