How do I include initial conditions in my program?
Afficher commentaires plus anciens
%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
Réponses (1)
Image Analyst
le 14 Déc 2013
0 votes
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 commentaires
Daisy
le 15 Déc 2013
Image Analyst
le 16 Déc 2013
What is "the sape of the string"? I don't know what sape means.
Catégories
En savoir plus sur Modeling dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!