Help Plotting Diffusion Equation in MatLab

18 visualizzazioni (ultimi 30 giorni)
I am currently working on a diffusion distribution project for an engineering class. The class requires me to use MatLab for many of the problems, a program that I have minimal experience with. Currently, I am trying to figure out how to plot Fick's second law (equation C(x,t)=N*e^(-x^2/(4Dt))/sqrt(4piDt), where D and N are given constants.). I was wondering if someone would be able to teach me how to plot this function in MatLab or provide a template script to use. The final result should look similar like this:
I would appreciate any help or hints that someone could provide. Thank you very much, and have a nice day.

Risposta accettata

Star Strider
Star Strider il 23 Set 2021
One option is to stack them in the same axes —
x = linspace(-200, 200);
v = logspace(-2, 2, 10);
y = exp(-(x./v(:)).^2);
y = 10×100
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0001 0.0003 0.0005 0.0009 0.0017 0.0029 0.0049 0.0183 0.0215 0.0251 0.0293 0.0341 0.0394 0.0455 0.0524 0.0601 0.0687 0.0783 0.0889 0.1007 0.1136 0.1278 0.1433 0.1601 0.1783 0.1979 0.2190 0.2416 0.2655 0.2910 0.3178 0.3459 0.3753 0.4059 0.4376 0.4702 0.5036
figure
plot(x, y)
grid
figure
plot(x, y+log(v(:)))
grid
Other options are subplot or stackedplot.
.

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by