Why doesn't my function work?
이전 댓글 표시
I want to create a function that outputs the gradient of a two variable function evaluated at a point (x,y) but it gives me this error message: Error using feval Function to evaluate must be represented as a string scalar, character vector, or function_handle object.
I need help :(
function [gradxy] = gradf(cord)
xcord=cord(1,1);
ycord=cord(1,2);
syms x y
fxy=@(x,y) x*(10*y+3)*exp(-x^2-y^2);
fx=diff(fxy,x);
fy=diff(fxy,y);
A(1)=feval(fx,xcord,ycord);
A(2)=feval(fy,xcord,ycord);
disp('gradient of f(x,y)');
disp(gradxy);
end
댓글 수: 2
Rik
2022년 3월 22일
In this expression
fxy=@(x,y) x*(10*y+3)*exp(-x^2-y^2);
The symbolic variables you created are ignored.
LAURA RODRIGUEZ VALVERDE
2022년 3월 22일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Subplots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!