Diferencia entre revisiones de «Usuario:Carlos Castro»

De MateWiki
Saltar a: navegación, buscar

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/mat/public_html/w/includes/diff/DairikiDiff.php on line 434
 
(No se muestran 3 ediciones intermedias del mismo usuario)
Línea 7: Línea 7:
 
: y(n+1) = y(n) + h y(n)(1 - y(n))
 
: y(n+1) = y(n) + h y(n)(1 - y(n))
 
*  MATLAB code   
 
*  MATLAB code   
: t0=0; tN=4; <br />
+
{{matlab|codigo=
: y0=1/10; <br />
+
% Euler method to solve the logistic equation y'=y(1-y)
: N=40; h=(tN-t0)/40; <br />
+
clear all;
:yy=y0; <br />
+
t0=0; tN=4;           % initial and final time
: y(1)=yy; <br />
+
y0=1/10;             % value of y at time t=0
: for n=1:N-1 <br />
+
N=40;                 % Number of intervals
: yy=yy+h*yy*(1-yy); <br />
+
h=(tN-t0)/40;         % Time step h 
: y(n+1)=yy; <br />
+
yy=y0;               % yy -> variable with the solution at each time step
: end <br />
+
y(1)=yy;             % y -> vector where we store the solution
: x=t0:h:tN; <br />
+
for n=1:N-1  
: plot(x,y,'x'); <br />
+
  yy=yy+h*yy*(1-yy); % numerical scheme
 +
  y(n+1)=yy;         % store the solution
 +
end  
 +
x=t0:h:tN;             % Draw the solution
 +
plot(x,y,'x');  
 +
}}
  
 
<gallery>
 
<gallery>

Revisión actual del 11:31 31 ene 2013

Resolución de la Ecuación logística por el método de Euler
  • Logistic equation:
y0 = f (t, y)=y(1-y);
y(t0) = y0:
  • Numerical scheme
y(0) = 1/10
y(n+1) = y(n) + h y(n)(1 - y(n))
  • MATLAB code
% Euler method to solve the logistic equation y'=y(1-y)
clear all;
t0=0; tN=4;           % initial and final time 
y0=1/10;              % value of y at time t=0
N=40;                 % Number of intervals 
h=(tN-t0)/40;         % Time step h  
yy=y0;                % yy -> variable with the solution at each time step
y(1)=yy;              % y -> vector where we store the solution
for n=1:N-1 
   yy=yy+h*yy*(1-yy);  % numerical scheme
   y(n+1)=yy;          % store the solution
end 
x=t0:h:tN;             % Draw the solution
plot(x,y,'x');