I currently have the output
If I only want to display the value of w(i,j) for, let's say, when xi=0.5 and tj=0.3 (so the answer should be -0.2781152949), how do I do it?
I wanna do something like
fprintf( 'The value of w when x = %.1f and t = %.1f is %.10f \n',xi, tj, wij(i,j));
l= 1;
T= 0.5;
alpha = 1;
m=10;
N=5;
syms f(x) g(x)
f(x)= 0.9*cos(2*pi*x);
g(x)= 0;
h=l/m;
k=T/N;
lambda=k*alpha/h;
wij = zeros(m,N);
for j=2:N
wij(1,j)=0;
wij(m,j)=0;
end
wij(1,1)=f(0);
wij(m,1)=f(l);
for i=2:m-1
wij(i,1)=f(i*h);
wij(i,2)=(1-lambda^2)*(f(i*h))+((lambda^2)/2)*(f((i+1)*h)+(f((i-1)*h))+k*(g(i*h)));
end
for j=2:N-1
for i=2:m-1
wij(i,j+1)=2*(1-lambda^2)*wij(i,j)+lambda^2*(wij(i+1,j)+wij(i-1,j))-wij(i,j-1);
end
end
disp('xi tj w(i,j)')
for j=1:N
t=j*k;
for i=1:m
x=i*h;
end
end