Fill in values in function

11 visualizzazioni (ultimi 30 giorni)
Annelotte
Annelotte il 27 Gen 2023
Modificato: Matt J il 27 Gen 2023
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?

Risposta accettata

Matt J
Matt J il 27 Gen 2023
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 Commenti
Annelotte
Annelotte il 27 Gen 2023
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 il 27 Gen 2023
Modificato: Matt J il 27 Gen 2023
Z is now a function.
surf(X,Y,Z(X,Y),'EdgeColor','none','LineStyle','none','FaceLighting','phong');

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by