Tengo este error, saben por que? Por favor
Publicado por JUAN ANGEL (17 intervenciones) el 01/10/2019 20:01:08

Valora esta pregunta


0
clear all;
clc;
prompt='Programa para resolver una matriz triangula inferior';
input(prompt);
a=input('Ingrese la mattriz de coeficientes ');
b=input('Ingrese el vector de constantes ');
x=input('Ingrese el vector inicial ');
e=input('Ingrese el error minimo ');
m=input('Ingrese el numero maximo de iteraciones');
jacob(a,b,x,e,m)
function v=jacob(a,b,x,e,m)
n=length(x);
for k=1:m
t=x;
for i=1:n
s=a(i,1:i-1)*t(1,i-1)+a(i,i+1:n)*t(i+1:n);
x(i)=(b(i)-s)/a(i,i);
end
if norm((x-t),inf)<e
return
end
end
v=x';
end
function jacobiforo
% a=input('Ingrese la mattriz de coeficientes ');
a=[10 -1 2 0; -1 11 -1 3 ;2 -1 10 0 ;0 3 -1 8 ];
% b=input('Ingrese el vector de constantes ');
b=[6; 25; -11; -11];
% x=input('Ingrese el vector inicial ');
x=zeros(4,1);
%e=input('Ingrese el error minimo ');
e=10^(-2);
%m=input('Ingrese el numero maximo de iteraciones');
m=100;
v=jacob(a,b,x,e,m)
end
function v=jacob(a,b,x,e,m)
n=length(x);
for k=1:m
t=x;
for i=1:n
if a(i,i)~=0
s=0;
for j=1:n
if j~=i
s=s+a(i,j)*t(j);
end
end
x(i)=(b(i)-s)/a(i,i);
end
end
if norm((x-t),inf)<e
v=x';
return
end
end
v=x';
end
> jacobiforo
v =
1.1032 2.9961 -1.0218 -2.6241
clear
prompt='Programa para resolver una matriz triangula inferior';
input(prompt);
a=input('Ingrese la mattriz de coeficientes ');
b=input('Ingrese el vector de constantes ');
x=input('Ingrese el vector inicial ');
e=input('Ingrese el error minimo ');
m=input('Ingrese el numero maximo de iteraciones');
jacob(a,b,x,e,m)
function v=jacob(a,b,x,e,m)
n=length(x);
for k=1:m
t=x;
for i=1:n
s=a(i,1:n)*t(1:n)-a(i,i)*t(i);
x(i)=(b(i)-s)/a(i,i);
end
if norm((x-t),inf)<e
break
end
end
v=x' ;
end
>> jacoforow1
Programa para resolver una matriz triangula inferior
Ingrese la mattriz de coeficientes [10 -1 2 0; -1 11 -1 3 ;2 -1 10 0 ;0 3 -1 8 ]
Ingrese el vector de constantes [6; 25; -11; -11]
Ingrese el vector inicial zeros(4,1)
Ingrese el error minimo 10^(-2)
Ingrese el numero maximo de iteraciones100
ans =
1.1032 2.9961 -1.0218 -2.6241
s=a(i,1:i-1)*t(1,i-1)+a(i,i+1:n)*t(i+1:n); original
s=a(i,1:i-1)*t(1:i-1)+a(i,i+1:n)*t(i+1:n); modificado
clear
prompt='Programa para resolver una matriz triangula inferior';
input(prompt);
a=input('Ingrese la mattriz de coeficientes ');
b=input('Ingrese el vector de constantes ');
x=input('Ingrese el vector inicial ');
e=input('Ingrese el error minimo ');
m=input('Ingrese el numero maximo de iteraciones');
jacob(a,b,x,e,m)
function v=jacob(a,b,x,e,m)
n=length(x);
for k=1:m
t=x;
for i=1:n
s=a(i,1:i-1)*t(1:i-1)+a(i,i+1:n)*t(i+1:n);
x(i)=(b(i)-s)/a(i,i);
end
if norm((x-t),inf)<e
break
end
end
v=x' ;
end
>> jacoforow2
Programa para resolver una matriz triangula inferior
Ingrese la mattriz de coeficientes [10 -1 2 0; -1 11 -1 3 ;2 -1 10 0 ;0 3 -1 8 ]
Ingrese el vector de constantes [6; 25; -11; -11]
Ingrese el vector inicial zeros(4,1)
Ingrese el error minimo 10^(-2)
Ingrese el numero maximo de iteraciones100
ans =
1.1032 2.9961 -1.0218 -2.6241