Plotting a Distribution of Molecules

1 view (last 30 days)
elle morey
elle morey on 15 Nov 2020
Commented: Star Strider on 15 Nov 2020
Need a figure for c(x,t)
t1=0;
t2=600;
t3=1200;
t4=1800;
t5=2400;
t6=3000;
t7=3600;
D=5e-9;
Co=1;
𝛿(𝑥−𝑥0)→∞ 𝑎𝑡 𝑥=𝑥0, and 𝛿(𝑥−𝑥0)=0 𝑓𝑜𝑟 𝑥≠𝑥0.
where 𝑐(𝑥,𝑡)= (Co/(sqrt(4*pi*D*t1)))exp^(-(x-xo)^2)/(4*D*t))

Answers (1)

Star Strider
Star Strider on 15 Nov 2020
The erf function is your friend!
Specifically:
x = linspace(-5, 5);
y = gradient(erf(x)) ./ gradient(x);
figure
plot(x, y)
grid
.
  4 Comments
elle morey
elle morey on 15 Nov 2020
how do i plot thatthen? i cant just use plot (c)can i?
Star Strider
Star Strider on 15 Nov 2020
No.
For a 3D plot (for a function with two arguments) use one of the surface plot functions.
t1=0;
t2=600;
t3=1200;
t4=1800;
t5=2400;
t6=3000;
t7=3600;
D=5e-9;
Co=1;
xo = 0;
c = @(x,t) (Co./(sqrt(4*pi*D*t1))) .* exp(-((x-xo).^2)./(4*D*t));
figure
fsurf(c, [1 10 0 10])
[X,T] = ndgrid(-5:01:5, 0.1:10);
figure
mesh(X, T, c(X,T))
grid on
This runs without error, however it doesn’t plot anything since all the elements of the matrix that ‘c’ produces are NaN.
You need to resolve that problem, so something shows up on the plot. I have no idea what you’re doing, so I can’t help you with that.

Sign in to comment.

Categories

Find more on 2-D and 3-D 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!