Plotting diffusion eq.
조회 수: 13 (최근 30일)
이전 댓글 표시
I'm stuck at plotting the solution to the diffusion equation. For the provided c and D, what would be optimal time and distance values?
x = 0:0.01:10^5;
t = [100 200 300];
c = 10^(-6);
D = 10^(-9);
figure(1)
x0 = [0 0 10^10];
u0 = [c 0 0];
plot(x0, u0)
hold on
for i = 1:3
dn = 2*D*sqrt(t(i));
e2 = erf( -x/dn );
u(i,:) = c*(1 + e2);
plot(x,u(i,:))
end
grid on
ylabel('Concentration (C) (mols/metres^{3})')
xlabel('Distance (x) (metres)')
legend('t = 0',['t = ' num2str(t(1))],['t = ' num2str(t(2))], ...
['t = ' num2str(t(3))])
댓글 수: 0
채택된 답변
Alan Stevens
2020년 11월 6일
Your x values are far too large! Try
x = (0:0.01:1)*10^-7; %%%%%%%%%%%%%%%%%%%
t = [100 200 300];
c = 10^(-6);
D = 10^(-9);
% figure(1)
% x0 = [0 0 10^10];
% u0 = [c 0 0];
for i = 1:3
dn = 2*D*sqrt(t(i));
e2 = erf( -x/dn );
u(i,:) = c*(1 + e2);
end
plot(x,u)
grid on
ylabel('Concentration (C) (mols/metres^{3})')
xlabel('Distance (x) (metres)')
legend(['t = ' num2str(t(1))],['t = ' num2str(t(2))], ...
['t = ' num2str(t(3))])
to get
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!