Help with plotting the figure
1 view (last 30 days)
Show older comments
I've developed the matlab code for the attached problem (Explicit method). It'll be helpful if someone check my code and correct me if I'm wrong. Also I need help for plotting the figure using contour map in two dimensions. And Finally how to add the stability requirement in the code? Matlab Code:
clc clear close all format long g
%step sizes delx=0.5; X=50; %delta x dely=0.5; Y=20; %delta y delt=1/20; T=20; %delta t Dx=1.0; Dy=0.2; %diffusivity coeff. rx=Dx*delt/delx^2; ry=Dy*delt/dely^2; n=X/delx; m=Y/dely; s=T/delt;
%Initial values C=zeros(n+1,m+1,s+1); %Dimention of the answer matrix
for i=(n/2+1-1/(2*delx)):(n/2+1+1/(2*delx)) for j=(m/2+1-1/(2*dely)):(m/2+1+1/(2*dely)) C(i,j,1)=1000; %initial concentration of the contaminant. end end
%Calculating each row Analytically
for k=1:s for j=2:m for i=2:n C(i,j,k+1)=(1-2*rx-2*ry)*C(i,j,k)+rx*C(i+1,j,k)+rx*C(i-1,j,k)+... ry*C(i,j+1,k)+ry*C(i,j-1,k); end end end
0 Comments
Answers (0)
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!