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

回答(1 个)

Image Analyst
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 个评论
Daisy
Daisy 2013-12-15
yes but I am not sure what the effects are. with the initial conditions the sape of the string should be visible but I am confused with what it (my decleared initial condition in the code) is meant to do, any explanation will do please.
Image Analyst
Image Analyst 2013-12-16
What is "the sape of the string"? I don't know what sape means.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by