Fill in values in function

7 次查看(过去 30 天)
I have the function Z = (1.5-X+X.*Y).^2 +(2.25-X+X.*(Y.^2)).^2+(2.625-X+X.*(Y).^3).^2.
How can I calculate Z(0,0) in my code?

采纳的回答

Matt J
Matt J 2023-1-27
Z = @(X,Y) (1.5-X+X.*Y).^2 +(2.25-X+X.*(Y.^2)).^2+(2.625-X+X.*(Y).^3).^2;
Z(0,0)
ans = 14.2031
  2 个评论
Annelotte
Annelotte 2023-1-27
This seems to work, but now I get an error on my surf function. Error shows this:
Error using surf (line 71)
Z must be a matrix, not a scalar or vector.
Error in GradientDescentTestFunction (line 27)
surf(X,Y,Z,'EdgeColor','none','LineStyle','none','FaceLighting','phong');
Matt J
Matt J 2023-1-27
编辑:Matt J 2023-1-27
Z is now a function.
surf(X,Y,Z(X,Y),'EdgeColor','none','LineStyle','none','FaceLighting','phong');

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by