Remove the discontinuity from tan(x) where odd multiples of pi/2

6 ビュー (過去 30 日間)
Giuseppe
Giuseppe 2014 年 3 月 20 日
回答済み: Lateef Adewale Kareem 2016 年 4 月 12 日
Hi i have the function;
f=tan(x)
where
x=linspace(-2pi,2pi,200)
I was wondering if you would know how to remove disconuity of the function which is odd multiples of pi/2.
I was thinking using the rem(x, 2) ==0 function and f(_) = NaN but i dont know how to structure it.
By the way it is for when i plot it, so there are no vertical lines (the disconuity which is all odd multiples of pi/2).

採用された回答

Star Strider
Star Strider 2014 年 3 月 20 日
編集済み: Star Strider 2014 年 3 月 20 日
I suggest:
x=linspace(-2*pi,2*pi,200);
f=tan(x);
f(diff([0 f]) < 0) = NaN;
  2 件のコメント
Giuseppe
Giuseppe 2014 年 3 月 20 日
thank you
Star Strider
Star Strider 2014 年 3 月 20 日
My pleasure!

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

その他の回答 (1 件)

Lateef Adewale Kareem
Lateef Adewale Kareem 2016 年 4 月 12 日
x=linspace(-2*pi,2*pi,200); f=tan(x); f(abs(diff([0 f])) > 15) = NaN;

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by