Make your own free website on Tripod.com
« May 2012 »
S M T W T F S
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
You are not logged in. Log in
Entries by Topic
All topics  «
Blog Tools
Edit your Blog
Build a Blog
RSS Feed
View Profile
My Blog
Tuesday, 20 January 2009
2
Mood:  a-ok

function x=fsub(A,b)   %xi=[bi - S(a(i,j)Xi)] / a(ii)% Sapo j=1 mexri i-1
[m,n]=size(A)
k=length(b)
if (m~=n | m~=k)
    error('diastaseis pinaka la8os h A den sumfwnei me b')
end
for i=1:(-1):1
    sum=0;
    for j=1:(i-1)
        sum=sum+A(i,j)*x(j);
    end
    x(i)=(b(i)-sum)/A(i,i);
end


 

function [A,b]=gauss1(A,b)
[m,n]=size(A);
k=length(b);
if (m~=n | m~=k)
    error('diastaseis pinaka la8os h A den sumfwnei me b')
end
for i=2:n
    l(i,1)=A(i,1)/A(1,1);
    b(i)=b(i)-l(i,1)*b(1);
    for j=1:n
        A(i,j)=A(i,j)-l(i,1)*A(1,j);
    end
end

 


function [A,b]=gauss2(A,b)
[m,n]=size(A);
k=length(b);
if (m~=n | m~=k)
    error('diastaseis pinaka la8os h A den sumfwnei me b')
end
for q=1:n-1
    for i=q+1:n
        l(i,q)=A(i,q)/A(q,q);
        for j=q:n
            A(i,j)=A(i,j)-l(i,q)*A(q,j);
        end
    end
    b(i)=b(i)-l(i,q)*b(q);
end
function [A,b]=gauss2sol(A,b)
[m,n]=size(A);
k=length(b);
if (m~=n | m~=k)
    error('diastaseis pinaka la8os h A den sumfwnei me b')
end
for q=1:n-1
    for i=q+1:n
        l(i,q)=A(i,q)/A(q,q);
        for j=q:n
            A(i,j)=A(i,j)-l(i,q)*A(q,j);
        end
    end
    b(i)=b(i)-l(i,q)*b(q);
end
for i=n:(-1):1
    sum=0;
    for j=(i+1):n
        sum=sum+A(i,j)*x(j);
    end
    x(i)=(b(i)-sum)/A(i,i);
end

function [p]=Jacobi(x);
for i = 1:15
p(i,1) = (7+x(2)-x(3))/4;
p(i,2) = (21+4*x(1)+x(3))/8;
p(i,3) = (15+2*x(1)-x(2))/5;
x = p(i,:)
end

function [x,y] = Euler(f,a,b,ya,n)
% This function uses Euler's method in order to integrate
% the differential equation y' = f(x,y) for x in the interval [a,b]
% and initial condition y(a) = ya.
% The function f is given in an M-file.
% The number of points for the integration is (n+1)
% x is an array of length n which contains the points of integration
% y is an array of length h which contains the computed function values
% y(i) is y(x(i)).
h = (b-a)/n ;
x = zeros(1,n+1) ;
y = zeros(1,n+1) ;
x = a:h:b ;
y(1) = ya ;
for i = 1:n
y(i+1) = y(i) + h*feval(f,x(i),y(i)) ;
end

 

function f1 = f1(x,y)
f1 = 2*x*y+3*x;


function [x,y] = Heun(f,a,b,ya,n)
% This function uses Heun's method in order to integrate
% the differential equation y' = f(x,y) for x in the interval [a,b]
% and initial condition y(a) = ya.
% The function f is given in an M-file.
% The number of points for the integration is (n+1)
% x is an array of length n which contains the points of integration
% y is an array of length h which contains the computed function values
% y(i) is y(x(i)).
h = (b-a)/n ;
x = zeros(1,n+1) ;
y = zeros(1,n+1) ;
x = a:h:b ;
y(1) = ya ;
hd2 = h/2 ;
for i = 1:n
ki = y(i) + h*feval(f,x(i),y(i)) ;
y(i+1) = y(i) + hd2*(feval(f,x(i),y(i)) + feval(f,x(i+1),ki)) ;
end

 


Posted by lamiaband at 7:19 AM EST
Updated: Tuesday, 20 January 2009 8:27 AM EST
1
Mood:  don't ask
function B=pin(A)
[m,n]=size(A)
for i=1:m
    sum=0;
    for j=1:n
        sum=sum+A(i,j);
    end
    B(i)=sum;
end

function x=bsub(A,b)   %xi=[bi - S(a(i,j)Xi)] / a(ii)% S apo i+1 mexri n
[m,n]=size(A)
k=length(b)
if (m~=n | m~=k)
    error('diastaseis pinaka la8os h A den sumfwnei me b')
end
for i=n:(-1):1
    sum=0;
    for j=(i+1):n
        sum=sum+A(i,j)*x(j);
    end
    x(i)=(b(i)-sum)/A(i,i);
end


Posted by lamiaband at 7:12 AM EST

Newer | Latest | Older