필터 지우기
필터 지우기

trying to find all critical points where gradient f = 0 but am getting an error.

조회 수: 3 (최근 30일)
This is what my code looks like right now. I am getting an error with the 'Real' part of my code with it saying that it is invalid.
%Storing the function f and g
syms w x y z;
f(w,x,y,z) = 2.0*w*x - 4.0*y - 5.0*w*y + 4.0*y*z + w^2 + 4.0*z^2;
g(w,x,y,z) = 0.4723*w*x + 0.6455*w*y + 0.1187*x*y + 0.8042*w^2 + 0.08831*x^2 + 0.2568*y^2 + 0.06482*z^2;
%Getting the derivatives of both functions
Dfw = diff(f,w);
Dfx = diff(f,x);
Dfy = diff(f,y);
Dfz = diff(f,z);
Dgw = diff(g,w);
Dgx = diff(g,x);
Dgy = diff(g,y);
Dgz = diff(g,z);
%Finding All Critical points by finding where gradient f is zero
[wSols, xSols, ySols, zSols] = solve([Dfw == 0, Dfx == 0, Dfy == 0, Dfz == 0], [w,x,y,z],'Real', 'true')

채택된 답변

Walter Roberson
Walter Roberson 2019년 11월 22일
Use 'Real', true instead of 'Real', 'true'
  댓글 수: 4
Peter Pyrka
Peter Pyrka 2019년 11월 22일
Okay but just to clarify, my output should be correct then with having only 1 solution for each and not more since it is strictly linear?
Walter Roberson
Walter Roberson 2019년 11월 22일
There would have to be a subexpression with degree 3 or higher for the partial derivatives to be non-linear, so having only one solution is expected for these.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by