Scilab

Se yon lojisyèl semi-lib pou kalkil syantifik

 Kèk egzanp pwogram Scilab 

Pwogram Scilab :
clear
clf

deff('[z]=f(x,y)','z=sin(x)*cos(y)')

xset('colormap',jetcolormap(32))

x=%pi*[-1:0.05:1]';y=x;z=feval(x,y,f);

subplot(2,2,1)
grayplot(x,y,z)

subplot(2,2,2)
contour2d(x,y,z,5)

subplot(2,2,3)
plot3d1(x,y,z,0,90)

subplot(2,2,4)
plot3d1(x,y,z,70,70)

Vibrasyon yon kòd ak twa amonik konbine
clear;
clf;

deff('[y] = note1(x,t)', 'y = sin(t)*sin(x)')
deff('[y] = note2(x,t)', 'y = 2/3*sin(t)*sin(x) + 1/3*sin(2*t)*sin(2*x)')
deff('[y] = note3(x,t)', 'y = 0.57*sin(t)*sin(x) + 0.29*sin(2*t)*sin(2*x) + 0.14*sin(3*t)*sin(3*x)')

x=0:0.1:%pi;

for i=0:9
   for j=0:9
      t=(i*10+j)*0.02*%pi;
      clf;
      y1=feval(x,t,note1);
      y2=feval(x,t,note2);
      y3=feval(x,t,note3);
      scf(0)
      subplot(3,1,1)
      plot2d(x,y1,rect=[0,-1,%pi,1],axesflag=0)
      subplot(3,1,2)
      plot2d(x,y2,rect=[0,-1,%pi,1],axesflag=0)
      subplot(3,1,3)
      plot2d(x,y3,rect=[0,-1,%pi,1],axesflag=0)  
      nom='test'+code2str(i)+code2str(j)+'.gif';
      xs2gif(0,nom,1)
   end;
end;

Siyal ak bri, analiz Fourye
clear;clf;

// ******************
// variable ajustable

p=0.1; // pas

// ******************
// variables de base

x=[0:p:20*%pi]'; // x du sinus
N=size(x);
n=N(1,1); // nombre de points
s=1/p*(1:n); // fréquences

// nombres aleatoires, loi uniforme

y2=0.2*(rand(n,1)-0.5);

// ******************
// Calcul

y1=sin(x);
y3=y1+y2;
z1=abs(fft(y1))^2;
z2=abs(fft(y2))^2;
z3=abs(fft(y3))^2;

for i=1:n
  if z1(i)>500 then z1(i)=500; end
  if z3(i)>500 then z3(i)=500; end
end

// ******************
// affichage

subplot(3,2,1)
plot2d(x,y1,style=2,rect=[0,-1.1,60,1.1])
xtitle('signal sinusoïdal','Temps','Intensité')

subplot(3,2,2)
plot2d(s,z1,style=2,rect=[0,0,0.03,50])
xtitle('TF signal sinusoïdal','Fréq.','Puissance')

subplot(3,2,3)
plot2d(x,y2,style=2,rect=[0,-1.1,60,1.1])
xtitle('bruit','Temps','Intensité')

subplot(3,2,4)
plot2d(s,z2,style=2,rect=[0,0,0.03,50])
xtitle('TF bruit','Fréq.','Puissance')

subplot(3,2,5)
plot2d(x,y3,style=2,rect=[0,-1.1,60,1.1])
xtitle('signal sinusoïdal bruité','Temps','Intensité')

subplot(3,2,6)
plot2d(s,z3,style=2,rect=[0,0,0.03,50])
xtitle('TF signal sinusoïdal bruité','Fréq.','Puissance')

 Yon ond ou bay enpilsyon sou li ki ap pwopaje kò l
clear;

Nx=35; // taille de la grille
Ny=27;
// Ny=5; // test
Nxaff = 30; // taille affichee
Nyaff = 26;
// Nyaff=4; // test
L=3; // largeur (loi empirique)

points_initiaux_x = zeros(Nx,Ny); // initialisation
points_initiaux_y = zeros(Nx,Ny);
for i=1:Nx
   for j=1:Ny
      points_initiaux_x(i,j) = i;
      points_initiaux_y(i,j) = j;
   end
end
points_finaux_y = points_initiaux_y;

// fonction

deff('[e]=profil(r)','e=r*exp(-(r/L)^2)'); // profil empirique

// programme principal

xmin = (Nx-Nxaff)/2+1;
xmax = Nx-xmin;
ymin = (Ny-Nyaff)/2+1;
ymax = Ny-ymin;
unite=0;dizaine=0; // pour le nom de fichier
for r=-1:0.5:Nx+1 // position du front d'onde
   intensite = 2; // variation avec la distance
   for i=1:Nx
      for j=1:Ny
         // e = deplacement du point
         e = intensite*profil(i-r);
         points_finaux_y(i,j) = points_initiaux_y(i,j) + e;
      end
   end
   // dessin
   clf;
   plot2d(0,0,-1,"010"," ",[xmin,ymin,xmax,ymax]) 
   for i=1:Nx
      for j=1:Ny
         xpoly(points_initiaux_x(i,:),points_finaux_y(i,:));
         xpoly(points_initiaux_x(:,j),points_finaux_y(:,j));
      end
   end
   nom='test\test'+code2str(dizaine)+code2str(unite)+'.gif';
   xs2gif(0,nom,0);
   unite = unite+1;
   if unite == 10 then
      dizaine = dizaine + 1;
      unite = 0 ;
   end
end

 Lojisyèl tankou li 
 PsiLAB, 
 AMESim,
 MatLab
 GNU Octave
 Sysquake
 Lyen 
Pajwèb ofisyèl Scilab
Pajwèb ofisyèl Scilab Enterprises
Man Scilab, yon èd pou pwograme sou li

Kategori:enfòmatik
Kategori:kalkil syantifik