function Solve_PDE
%******************************************
% Author: Jiansen Lu, Date:
% Purpose: A example to solve PDE in MATLAB
%reference: Partial Differential Equations in MATLAB
% Slove dv/dt=(0.1+0.2cost) d/dx(dv/dx) for x between 0 and 1
%v(x, 0) = 2*x-2*x*x, v(0,t)=0 and v(1,t)=0
%**************************************************
%PDE1: MATLAB script M-file that solves and plots
%solutions to the PDE stored in eqn1.m
%solutions to the PDE stored in eqn1.m
m = 0;
%NOTE: m=0 specifies no symmetry in the problem. Taking
%m=1 specifies cylindrical symmetry, while m=2 specifies
%spherical symmetry.
%%Define the solution mesh
x = linspace(0,1,20);
t = linspace(0,1,10);
%Solve the PDE
u = pdepe(m,@eqn1,@initial1,@bc1,x,t)
%first is t, second is x, check middle point
u(10,10)
% check if answer reasonalbe
check1=u(1,:)-initial1(x)
check2=u(:,1)
check3=u(:,20)
function [c,b,s] = eqn1(x,t,u,DuDx)
%EQN1: MATLAB function M-file that specifies
%a PDE in time and one space dimension.
c = 1/(0.1+0.2*cos(t));
b = DuDx;
s = 0;
function [pl,ql,pr,qr] = bc1(xl,ul,xr,ur,t)
%BC1: MATLAB function M-file that specifies boundary conditions
%for a PDE in time and one space dimension.
pl = ul;
ql = 0;
pr = ur;
qr = 0;
function value = initial1(x)
%INITIAL1: MATLAB function M-file that specifies the initial condition
%for a PDE in time and one space dimension.
value = 2.*x-2.*x.*x;
Online computer courses, code, programming tutorial and sidebar information for monitoring Canadian S&P/TSX index. Build friendship and networking. Welcome to visit my blogs often!!! I also have two other sites: YouTube Channel and Google site.
Adsense
Popular Posts
- PHPWind-- A PHP forum script applcaition in China
- Formatting my post
- How to blend adsense inside your post?
- Notepad++ - Add C++ compiler
- Set up a child account and set screen time limit in Windows 8
- Wayback Machine - see archived versions of web pages across time
- Install PHPMailer 5.2.4 and use smtp gmail
- phpexcel toggle expand and hide column in EXCEL and summary
- Install PHP ibm_db2 extension in Linux (redHat)
- PHP: add a download as pdf file button in report page
No comments:
Post a Comment