Why this function is wrong written
显示 更早的评论
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
2017-5-30
Show the full code.....
Dennis Semke
2017-5-30
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
2017-5-30
KSSV
2017-5-30
YOu can mesh plot it..look at my answer....it is a mesh plot.
采纳的回答
更多回答(3 个)
KSSV
2017-5-30
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
2017-5-30
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);
类别
在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!