Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //MAHJOUB BONNAIRE
- //provence
- //L3 Meca
- //Programe d'interpolation de lagrange
- //Debut du programme
- //nettoyage du cache
- clear
- clf(1)
- //RECUPERATION DONNEES
- //Dir(school)
- //A=fscanfMat('\\ad.u-ga.fr\home_etu\m\mahjoubp\Bureau\Scillab\TP3\data.sce')
- //Dir(home)
- A=fscanfMat('/home/provence/Bureau/scilab-6.0.1.bin.linux-x86_64/scilab-6.0.1/projet/apdata/data_lagrange_2.sce')
- //Input #1
- N=size(A)
- n=N(1,1)
- p=input("Quel pas voulez vous ? (x)")
- //initialisation de xinc
- xinc=0
- xd=A(1,1)
- xu=A(n,1)
- nx=(xu-xd)/p
- //declaration des tab
- x=zeros(n,1)
- y=zeros(n,1)
- X=zeros(n+nx,1)
- Y=zeros(n+nx,1)
- //Input #2
- k=1
- while k<n+1
- x(k)=A(k,1)
- y(k)=A(k,2)
- k=k+1
- end
- //declaration de fonction
- function [p]=Pn(n,x,y,xinc)
- Lk=1
- k=1
- i=1
- pp=0
- while i<n+1
- while k<n+1
- if k<>i then
- Lk=Lk*(xinc-x(k))/(x(i)-x(k))
- end
- k=k+1
- end
- k=1
- pp=pp+y(i)*Lk
- Lk=1
- i=i+1
- end
- p=pp
- endfunction
- //utilisation de la fonction Pn
- //res=Pn(n,x,y,xinc)
- //disp(res)
- //Remplissage de X et Y
- function [X,Y,btf]=Coord(n,x,y,xinc,res)
- k=1
- kk=1
- tf=0
- btf=1
- while k<n+1
- if x(k,1)>xinc & tf==0
- tf=1
- btf=0
- // ATTENTION : BUG !
- /*Le programme rentre dans cette condition alors que xinc==x(k)
- disp(x(k),"xxxxxxxxxxxx")
- disp(xinc,"xiiiiiiiiiii")
- */
- X(kk+1)=x(k)
- X(kk)=xinc
- Y(kk+1)=y(k)
- Y(kk)=res
- kk=kk+1
- end
- if x(k,1)==xinc
- // ATTENTION : BUG !
- //Le programme ne rentre pas dans cette condition alors que xinc==x(k)
- disp(x(k),"xxxxxxxxxxxx")
- disp(xinc,"xiiiiiiiiiii")
- tf=1
- X(kk)=x(k)
- Y(kk)=y(k)
- end
- if x(k,1)>xinc & tf==1
- X(kk)=x(k)
- Y(kk)=y(k)
- end
- if x(k,1)<xinc then
- X(kk)=x(k)
- Y(kk)=y(k)
- end
- k=k+1
- kk=kk+1
- end
- endfunction
- //utilisation de la focntion Coord
- //[X,Y]=Coord(n,x,y,xinc,res)
- //disp(X)
- //disp(Y)
- //Fonction d'incrementation de pas
- function [XY]=incp(n,x,y,p,nx,xd)
- k=1
- xinc=xd+p
- while k<nx
- res=Pn(n,x,y,xinc)
- [X,Y,btf]=Coord(n,x,y,xinc,res)
- x=X
- y=Y
- if btf==0 then
- n=n+1
- end
- xinc=xinc+p
- k=k+1
- end
- XY=[X,Y]
- endfunction
- //utilisation de la fonction incp
- [XY]=incp(n,x,y,p,nx,xd)
- disp(XY)
- //fonction de tracage
- function graph(XY)
- xset("window",1)
- S=size(XY)
- s=S(1,1)
- k=1
- while k<s
- plot([XY(k,1),XY(k+1,1)],[XY(k,2),XY(k+1,2)])
- k=k+1
- end
- endfunction
- //utilisation de la fonction de tracage
- graph(XY)
Add Comment
Please, Sign In to add comment