[Scilab-users] Use of show_pixmap() obsolete. Alternative??
Eliseo Chacon Vera
eliseo at um.es
Thu Nov 8 23:14:27 CET 2012
Dear Samuel,
thanks for your quick answer. The following lines solve the heat equation and provides
a smooth evolution of the solution in the plot. SCILAB 5.3.3 likes but SCILAB 5.4.0 does not like it.
thanks,
eliseo (hope this time gets to the list right)
///
// heat equation
//
clear;
//
// Initial value
//
function z=u0(xx)
if (abs(xx)<=1) then
z=1;
else
z=0;
end
endfunction
//
// b heat coef.
//
b=1;
f0=scf(0);
f0.pixmap='on';
clf(f0);
show_window();
//
// space interval
//
xmin=-5;
xmax=5;
Nx=125; // Number of points
h=(xmax-xmin)/Nx;
x=xmin:h:xmax;
//
u=zeros(1,Nx+1);
uold=zeros(1,Nx+1);
u2=zeros(1,Nx+1); // dimensionamos inicialmente a cero
uold2=zeros(1,Nx+1);
ucero=zeros(1,Nx+1);
//
// time
//
t0=0;
time=t0;
for i=1:Nx+1
uold(i)=u0(x(i)); // initial value
uold2(i)=u0(x(i));
ucero(i)=u0(x(i));
end
plot(x,uold,'dr')
ejes=gca();
ejes.data_bounds=[xmin, 0; xmax,1.2];
title(" Initial data ");
show_pixmap();
sleep(1000);
k=0.9*h^2/(2*b);// stability
//
// coeficiente mu=k/h^2
//
mu=k/h^2;
//
coef1=b*mu;
coef2=1-2*b*mu;
coef3=b*mu;
//
while (time<0.5)
time=time+k;
u(1)=0;
u(Nx+1)=0;
for i=2:Nx
u(i)=coef1*uold(i+1)+coef2*uold(i)+coef3*uold(i-1);
end
clf(f0);
plot(x,u,'or',x,ucero,'db');
ejes=gca();
ejes.data_bounds=[xmin, 0; xmax,1.2];
title("Euler explicit: time= "+string(time)..
+"; time step = "+string(k)+..
+"; spatial h="+string(h)+"; diffusion = "+string(b));
legend('b=1','initial');
show_pixmap();
uold=u;
sleep(1);
end
--
View this message in context: http://mailinglists.scilab.org/Use-of-show-pixmap-obsolete-Alternative-tp4025179p4025186.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20121108/aa6e15b7/attachment.htm>
More information about the users
mailing list