Help Plotting Diffusion Equation in MatLab

조회 수: 4 (최근 30일)
Anthony Koning
Anthony Koning 2021년 9월 23일
답변: Star Strider 2021년 9월 23일
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.

채택된 답변

Star Strider
Star Strider 2021년 9월 23일
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.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by