Evaluating Nested Function Handles

6 ビュー (過去 30 日間)
Hasan Abbas
Hasan Abbas 2016 年 8 月 15 日
コメント済み: Hasan Abbas 2016 年 8 月 16 日
I have a function that I would like to define in steps. e.g.,
y1 = @(x) 1./sqrt(1 - x.^2);
y2 = @(x) 1./sqrt(1 + x.^2);
T = (y2 -y1)./(y2 + y1);
How can I directly evaluate T in terms of the underlying variable x, i.e. T(x)?
  2 件のコメント
per isakson
per isakson 2016 年 8 月 15 日
Did you try
T = @(x) (y2(x) -y1(x))./(y2(x) + y1(x));
and
>> T(0.4)
ans =
-0.0805
>> T(1)
ans =
NaN
>> T(1-eps)
ans =
-1.0000
Hasan Abbas
Hasan Abbas 2016 年 8 月 16 日
Thanks Per!
It did the trick.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by