How do I include initial conditions in my program?
조회 수: 1 (최근 30일)
이전 댓글 표시
%Begin with global parameters,
L = 0.64; % length of string (m)
xo=L/2; % mid-section of string
T = 122; % tensile force of the string (N)
S=pi/(4e-6); % section of the string
rho = 7.8e6; % mass per unit length of string (kg/m)
c = sqrt(T/rho*S); % wave velocity (m/s)
h=5; % height of string when plucked
% end global parameter
% stability condition/scheme parameters....................................................
nt=6; % number of time discretisation
t0=0; % initial time value
tf=0.3; % final time value in seconds
dt=0.005; %dt=0.00025; %dt=tf/(nt-1);; % time step
t = linspace(0,tf,nt); %t=(t0:dt:tf); % time division
nx=10; % initial number of spatial discretisation with first and last nodes
dx=L/nx; %
x=linspace(0,L,nx) ; % x subdivisions on string
x0= 0; x(:,end)=0; % boundary conditions
nx=nx-2 ; % resetting number of spatial discretisation without first and last nodes
% constructing matrices M and K...........................................
cfl=c*(dt/dx); % CFL condition........STABILITY CHECKER
[M]=toeplitz([(1/c) 0 zeros(1,nx)],[(1/c) 0 zeros(1,nx)]);
[K]=toeplitz([(-2/(dx)^2) (1/(dx)^2) 0 zeros(1,nx-1)],[(-2/(dx)^2) (1/(dx)^2) 0 zeros(1,nx-1)]);
[H]=inv(M);
% initial conditions....
U=zeros(nt,nx+2); %U(space,time)
if x<=xo
U(:,nx) = (h*(x./xo)) %U((1:nx),1) U(:,1)
else
U(:,nx) = (h.*((L-x)./(L-xo))) %U(:,2)
end
댓글 수: 0
답변 (1개)
Image Analyst
2013년 12월 14일
You are already defining some initial values for lots of parameters. I don't know why you are asking since you seem to know how to do it.
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!