My function is: funk1=3*((1-x).^2)*exp(-x.^2-(y+1).^2) and matlab send me and error but don't write where it is.

5 件のコメント

KSSV
KSSV 2017 年 5 月 30 日
Show the full code.....
Dennis Semke
Dennis Semke 2017 年 5 月 30 日
x=linspace(-3,3,49); y=linspace(-3,3,49); funk1=3*((1-x).^2)*exp(-x.^2-(y+1).^2); mesh(funk1)
Stephen23
Stephen23 2017 年 5 月 30 日
It works for me:
>> x = 2;
>> y = 3;
>> 3*((1-x).^2)*exp(-x.^2-(y+1).^2)
ans = 6.1835e-009
Whatever you are doing is causing an error.
Dennis Semke
Dennis Semke 2017 年 5 月 30 日
hm i dont know why because matlab send me everytime the error 'Error in matlab_blatt6_1 (line 3) funk1=3*((1-x).^2)*exp(-x.^2-(y+1).^2)
so i cant meshplot it...
KSSV
KSSV 2017 年 5 月 30 日
YOu can mesh plot it..look at my answer....it is a mesh plot.

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

 採用された回答

Stephen23
Stephen23 2017 年 5 月 30 日
編集済み: Stephen23 2017 年 5 月 30 日

0 投票

F = 3*((1-x).^2).*exp(-x.^2-(y+1).^2);
^ you need this .
Read about the difference here:

その他の回答 (3 件)

KSSV
KSSV 2017 年 5 月 30 日

0 投票

x=linspace(-3,3,49);
y=linspace(-3,3,49);
[X,Y] = meshgrid(x,y) ;
funk1=3*((1-X).^2).*exp(-X.^2-(Y+1).^2);
surf(X,Y,funk1)
Rik
Rik 2017 年 5 月 30 日

0 投票

The error explains exactly what is wrong: "Error using * Inner matrix dimensions must agree."
You forgot the dot for element-wise multiplying before the exp.
x=linspace(-3,3,49);
y=linspace(-3,3,49);
funk1=3*((1-x).^2).*exp(-x.^2-(y+1).^2);
Dennis Semke
Dennis Semke 2017 年 5 月 30 日

0 投票

Ou ok now it works. Big ty :) I rly dont saw it and made me angry :'D

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2017 年 5 月 30 日

コメント済み:

2017 年 5 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by