MATLAB Answers

Obtain single equation from a system of equations stored as an anonymous function

조회 수: 3(최근 30일)
Kostas 24 Feb 2020
댓글: Star Strider 24 Feb 2020
Hi all,
I would like to ask if it is possible to use some sort of notation or other trick, such that I can obtain one of the two equations that I have stored in a system of anonymous functions.
In specific, I have a system of two equations, in the following anonymous function:
F = @(x) [x(1).*x(2).^2 + sin(x(2)) ; ...
cos(x(1)) + x(2).^3 ] ;
And I would like to obtain:
f = @(x) x(1,:).*x(2).^2 + sin(x(2))
Is it possible to do this by some sort of notation such as F.1, F{1}, etc.?

  댓글 수: 0

로그인 to comment.

채택된 답변

Star Strider
Star Strider 24 Feb 2020
Not directly.
I would do this:
F = @(x) [x(1).*x(2).^2 + sin(x(2)) ; ...
cos(x(1)) + x(2).^3 ] ;
z = [2 6];
Q = F(z);
Result = Q(1);

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.

Translated by