フィルターのクリア

components of vector valued functions

6 ビュー (過去 30 日間)
Wilhelm
Wilhelm 2014 年 2 月 3 日
コメント済み: Wilhelm 2014 年 2 月 3 日
Given
F=@(x,y) [x+y,x-y.^2]
how do I refer to the second component of that function;
the command
syms x,y; F(x,y)(2)
gives an error, though I would expect to get x-y^2. My goal is to define a new function which only contains one particular component of a vector field like
f2=@(x,y) F(x,y)(2)
Probably simple but I did not find the correct syntax.

採用された回答

Walter Roberson
Walter Roberson 2014 年 2 月 3 日
VSelect = @(V,IDX) V(IDX);
F = @(x,y) [x+y,x-y.^2]
f2 = @(x,y) VSelect(F(x,y),2);
There is no good direct way to do it. There is a way to do it all in one function call, but it is somewhat ugly and not easy to read.
  1 件のコメント
Wilhelm
Wilhelm 2014 年 2 月 3 日
Thx! Not obvious, though ...

サインインしてコメントする。

その他の回答 (1 件)

Wilhelm
Wilhelm 2014 年 2 月 3 日
編集済み: Walter Roberson 2014 年 2 月 3 日
That gives
>> syms z
>> F(1,z)
ans =
[ z + 1, 1 - z^2]
in my example.
I want to define a new function handle however which yields the second component x-y^2 only (for my example).
Or did I misunderstood your answer?

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by