Conditional sequence generator for sinus

1 回表示 (過去 30 日間)
Sferle Alin-Tudor
Sferle Alin-Tudor 2021 年 9 月 21 日
回答済み: Srijith Kasaragod 2021 年 9 月 24 日
Hi, I'm trying to generate a function for a sequence like:
x(n)={ sin(0.2*n),n>10 n is between 0 and 20
0,n<=10
I tried to solve the problem but only the ramp example came to my mind at this moment like x=sin(0.2*(n>10)) which is an complete incorrect solution.

採用された回答

Srijith Kasaragod
Srijith Kasaragod 2021 年 9 月 24 日
Hi,
One way to generate the sequence is to use relational operators to assign values to variable 'x'. Following lines of code shows the same.
n=0:20;
x(n>10)= sin(0.2*n(n>10));
x(n<=10)= 0;
Pleasre refer this documentation to read more on how to filter elements of an array by applying conditions to the array.

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by