How do I include initial conditions in my program?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
%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 Kommentare
Antworten (1)
Image Analyst
am 14 Dez. 2013
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 Kommentare
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!