필터 지우기
필터 지우기

How do I include initial conditions in my program?

조회 수: 1 (최근 30일)
Daisy
Daisy 2013년 12월 14일
댓글: Image Analyst 2013년 12월 16일
%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