フィルターのクリア

How to check if an integer is above or below 0.5 continuously ?

1 回表示 (過去 30 日間)
Nuri Efe TATLI
Nuri Efe TATLI 2022 年 12 月 8 日
編集済み: Dyuman Joshi 2022 年 12 月 8 日
Hello everyone.
I have a periodic signal where I try to condition the signal's behavior to be zero in certain parts.
What I'm trying to do exactly is this:
The period of the signal is T.
I want the signal to have some value when 0<time<T/2 and I want signal to have a value of zero when T/2 <= time < T. But I want to do this continuously until the time stops. So for example signal should have a value of zero when 3T/2 <= time < 2T as well.
To put it in words, I want to make a periodic wave's second half equal to zero in every cycle.
How may I do this ?
If it is hard to understand with text:
Red parts should be zero.

採用された回答

Dyuman Joshi
Dyuman Joshi 2022 年 12 月 8 日
編集済み: Dyuman Joshi 2022 年 12 月 8 日
If you have numeric data, you can do something like this -
x=0:0.01:3;
y=abs(sin(pi*x));
%original plot
plot(x,y,'k-')
hold on
%modified plot
y(ceil(x)==round(x))=0;
plot(x,y,'b.')
Note - use a tolerance based method rather than == for floating point numeric values
%for example
y(abs(ceil(x)-round(x))<1e-4)=0
  3 件のコメント
Nuri Efe TATLI
Nuri Efe TATLI 2022 年 12 月 8 日
Is it possible to implement this if I want to make first half cycle zero instead of second ?
Dyuman Joshi
Dyuman Joshi 2022 年 12 月 8 日
編集済み: Dyuman Joshi 2022 年 12 月 8 日
change ceil to floor
x=0:0.01:3;
y=abs(sin(pi*x));
%original plot
plot(x,y,'k-')
hold on
%modified plot
y(abs(floor(x)-round(x))<1e-4)=0;
plot(x,y,'b.')

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by