Info

This question is closed. Reopen it to edit or answer.

Hai...need help for this Matlab code..why the output can't come out..already try in many way...anyone??...plez help me

1 view (last 30 days)
%function u=pdehypwave(c,L,Tmax,h,k,c1,c2,f,g)
%Filename:pdehypwave.m
%Usage: u=pdehypwave(c,L,Tmax,h,k,c1,c2,f,g)
%To solve wave equation c^2u_xx=u_tt, 0<x<L, t>0
%with the boundary conditions
% u(0,t=c1, u(L,t)=c2, t>0
%and the initial condtions
% u(x,0)=f(x), 0<=x<=L
% u_t(u(x,0))=g(x), 0<=x<=L
%(c)C.R.C.Teh
%INPUT
%Filename: pdehypwave_in.m
c=1; %coefficient in PDE; c^2u_xx=u_tt
L=pi; %length of string in x direction
Tmax=1; %maxmimum time t
h=0.3142; %step size for space x
k=0.5; %step size for space t
c1=0; %BC1: w(0,t)=c1 at x=0
c2=0; %BC2: w(pi,t)=c2 at x=pi
f=inline('0','x'); %IC1: w(x,0)=f(x) at t=0
g=inline('0','x'); %IC2: w_t(w(x,0))=g(x) at t=0
%OUTPUT
%u matrix of solution value
n=L/h; %number of subinterval of [0,a]
m=Tmax/k; %number of subinterval of [0,b]
N=n+1; %number of grids [0=x1,x2,....,xN=a]
M=m+1; %number of grids [0=y1,y2,....,yN=a]
x=0:h:L; %x grids
t=0:k:Tmax; %t grids
w=zeros(1.4,1); %initialization matrix solution u
for i=2:N
w(i,1)=f(x(i)); %IC1: initial values
end
for j=1:M
w(i,j)=c1; %BC1: boundary values
w(N,j)=c2; %BC2: boundary values
end
r=c*k/h;
%EXPLICIT METHOD
for j=3:M %time loop
end
for i=2:N-1 %space loop
end
if j==3
w(i,j+1)=(2-2*c^2*r^2)*w(i,j)+(c^2*r^2)*w(i-1,j)+(c^2*r^2)*w(i+1,j)-w(i,j-1)+k^2*sin(u(i,j)-w(i,j));
end
disp('--------------------------------------')
fprintf(' u=x\\t')
fprintf(' %4,2f ',t)
fprintf('\n')
disp('--------------------------------------')
for i=1:N
fprintf(' %4.4f',x(i))
for j=1:M
fprintf('%10.4f',u(i,j))
end
fprintf('\n')
end
*The question need me to come out the value from this code by using Explicit scheme.
*here the value given
k=0.05
r=0.1592
c=1
r=0.15925
a=1
*boundary condition
w(0,t)=0, w(pi,t)=0 0 less and equal x less and equal pi, 0 less and equal t less and equal a
*Initial condition
w(x,0)=0 wt(x,0)=0
*the formula is
w(i,j+1)=(2-2*c^2*r^2)*w(i,j)+(c^2*r^2)*w(i-1,j)+(c^2*r^2)*w(i+1,j)-w(i,j-1)+k^2*sin(u(i,j)-w(i,j));
*for i=2 to n-1,evaluate the initial condition.
*for j=3:M,for i=2:n-1 evaluate the formula
  9 Comments
ZARITH SOFIA
ZARITH SOFIA on 25 Nov 2013
actually i'm not familiar with this web...this is my first time that's why it easy for me to communicate via email.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!