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일

1 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2023년 1월 27일

편집:

2023년 1월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by