Creating a simple plot

6 ビュー (過去 30 日間)
Vaultec
Vaultec 2014 年 10 月 1 日
編集済み: Rick Rosson 2014 年 10 月 1 日
Im trying to plot y=x*e^(-x^2) where the range of x is from -3,3
Ive tried running
x = -3:3; y = x*exp(-x.^2); plot (x, y) however i keep getting the error Inner matrix dimensions must agree. Not quite sure what that means

採用された回答

Rick Rosson
Rick Rosson 2014 年 10 月 1 日
編集済み: Rick Rosson 2014 年 10 月 1 日
Use .* instead of * here:
y = x.*exp(-x.^2);
Also, you will want higher resolution:
x = -3:0.01:3;

その他の回答 (2 件)

Michael Haderlein
Michael Haderlein 2014 年 10 月 1 日
You need element-wise multiplication:
x = -3:3;
y = x.*exp(-x.^2); %<-- here, I added the point
plot (x, y)

Vaultec
Vaultec 2014 年 10 月 1 日
ok thanks worked out perfectly

カテゴリ

Help Center および File Exchange2-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