complementary error function (surf plot)

1 回表示 (過去 30 日間)
Stephanie Anderson
Stephanie Anderson 2021 年 1 月 15 日
コメント済み: Star Strider 2021 年 1 月 16 日
I'm new to MATLAB and i'm trying to plot the following function with surf:
.
Parameter values:
My code so far:
x = linspace(0,10^(-6),20);
t = linspace(0,5,5);
u0 = 10^(-6);
k = 10^(-9);
dn = 2.*k.*sqrt(t);
e2 = erf( x.*(dn).^(-1) );
u = u0.*(1 - e2);
surf(x,t,u)
title('Complementary Error function from 0 to 10^(-6)')
xlabel('Distance x')
ylabel('Time t')
I'm trying to get the x between 0 to in increments of and t in increments of .
How do you fix this?

採用された回答

Star Strider
Star Strider 2021 年 1 月 15 日
Add:
[X,T] = ndgrid(x,t);
and it works:
x = linspace(0,10^(-6),20);
t = linspace(0,5,5);
[X,T] = ndgrid(x,t);
u0 = 10^(-6);
k = 10^(-9);
dn = 2.*k.*sqrt(T);
e2 = erf( X.*(dn).^(-1) );
u = u0.*(1 - e2);
surf(X,T,u)
title('Complementary Error function from 0 to 10^(-6)')
xlabel('Distance x')
ylabel('Time t')
although you may want to revise the code a bit.
  4 件のコメント
Stephanie Anderson
Stephanie Anderson 2021 年 1 月 16 日
Thank you StarStrider and Paul for your explanations.
Star Strider
Star Strider 2021 年 1 月 16 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital Filter Analysis についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by