"Check for incorrect argument data type or missing argument in call to function 'X'. Error in sum=sum+A(j,h)*X(h)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Avelon Jr Eugenio
le 5 Déc 2021
Commenté : Avelon Jr Eugenio
le 5 Déc 2021
output= ('Gaussian Elimination Method')
A=input ('Enter your coefficient Matrix')
b=input ('Enter your space vector')
N=length(b);
x=zeros(N,1);
for j=1:1:N-1 %Forward Elimination
for i = j+1:1:N
m=A(i,j)/A (j,j);
A(i,:)=A(i,:)- m*A(j,:)
b(i) = b(i) - m*b(j)
end
end
disp([A,b]);
for j=N:-1:1%Backward Elimination
sum=0;
for h=1+1:1:N
sum=sum+A(j,h)*X(h);
end
X(j)=(b(j)-sum)/A(j,j);
end
disp(X);
0 commentaires
Réponse acceptée
Chunru
le 5 Déc 2021
output= ('Gaussian Elimination Method')
% A=input ('Enter your coefficient Matrix')
% b=input ('Enter your space vector')
A = randn(3,3);
b = randn(3,1)
N=length(b);
X=zeros(N,1); % upper case X (use case carefully)
for j=1:1:N-1 %Forward Elimination
for i = j+1:1:N
m=A(i,j)/A (j,j);
A(i,:)=A(i,:)- m*A(j,:)
b(i) = b(i) - m*b(j)
end
end
disp([A,b]);
for j=N:-1:1%Backward Elimination
s=0; % try not use sum as variable as it is a built in function
for h=1+1:1:N
s=s+A(j,h)*X(h);
end
X(j)=(b(j)-s)/A(j,j);
end
disp(X);
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!