Sei sulla pagina 1di 2

05/07/14 07:58

C:\Users\RAJESH01AG\Documents\MATLAB\legendregen01.m

clc
m=input('order of difference equation ');
n=input('number of points upto u want to calculate' );
h=input('enter value of h');
w=input('enter order of legendre func');
a=zeros(n,n+m);
b=zeros(10,1);
c=zeros(10,1);
d=zeros(10,1);
e=zeros(n,1);
x=zeros(n,1);
f=zeros(n);
r=zeros(n);
q=zeros(n);
disp('enter initial conditions');
j=input('enter the position of condition');
y(j+1)=input('enter the condition now');
k=input('enter the position of 2nd condition');
y(k+1)=input('enter the 2nd condition now');
for i=1:n;
x(i)=(i)*h;
end
for i=1:n;
a(i,i)=((1-(x(i)).^2)+(x(i).*h));
a(i,i+1)=((12*h^2)-(2*(1-(x(i)).^2)));
a(i,i+2)=((1-(x(i)).^2)-(x(i).*h));
end
for i=1:n;
c(i)=a(i,j+1)*y(j+1);
end
for i=1:n;
d(i)=a(i,k+1)*y(k+1);
end
for i=1:n;
e(i)=0-c(i)-d(i);
end
q=a;
for l=1:n;
q(l,j+1)=0;
q(l,k+1)=0;
end
disp(q);
q(:, find(sum(abs(q)) == 0)) = [];
disp(a);
disp(b);
disp(c);
disp(d);
disp(x);
disp(e);
disp(q);
f=q;r=inv(f);
u=det(f);
disp(u);
if(u==0)

1 of 2

05/07/14 07:58

C:\Users\RAJESH01AG\Documents\MATLAB\legendregen01.m

disp('solution does not exists');


else
disp('solution of equ exists');
end
e=r*e;
for i=1:n;
if (i~=j+1 && i~=k+1)
y(i)=e(i-1);
end
end
disp(y);

2 of 2

Potrebbero piacerti anche