Having trouble graphing a non-linear graph

x = -2:0.1:2;
y = cos(x)+exp(-1/2*x.^2)*sin(6*x)
plot(x,y)
This is my code, I keep getting
Error in test (line 2) y = cos(x)+exp(-1/2*x.^2)*sin(6*x);
But I cant figure out what I am doing wrong.

 採用された回答

Stephan
Stephan 2018 年 9 月 16 日
編集済み: Stephan 2018 年 9 月 16 日

0 投票

x = -2:0.01:2;
y = cos(x)+exp(-1/2*x.^2).*sin(6*x);
plot(x,y)

2 件のコメント

Nirvan Hashemian
Nirvan Hashemian 2018 年 9 月 16 日
Thank you!
Neelanjan Pal
Neelanjan Pal 2019 年 11 月 16 日
編集済み: Neelanjan Pal 2019 年 11 月 16 日
when the code is as SUCH;
syms x y C
x = -2:0.01:2;
C=12/(cos(x)+exp(-1/2*x.^2).*sin(6*x));
plot(x,C)
error:
Error using /
Matrix dimensions must agree.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraph and Network Algorithms についてさらに検索

タグ

質問済み:

2018 年 9 月 16 日

編集済み:

2019 年 11 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by