Generating a cosine wave with variable frequency where frequency is an output from a lookup table
4 ビュー (過去 30 日間)
古いコメントを表示
I am trying to generate a sine/cosine wave with a variable frequency. Here's how I did it.
I took a PN sequence generator with samples per frame 3 and converted those three samples in 1 frame to a decimal number by a MATLAB function block and passes it to a lookup table (1-D) as breakup points [0;1;2;3;4;5;6;7] and gave some data [100;200;300;400;500;600;700;800]. This data is given to a MATLAB function block which takes the values of the lookup table and time from clock block and gives me the result cos(2*pi*f*t). Atleast, this is what it looks like. But, when I ran it oscilloscope haven't shown me any cosine waves rather, it showed me a constant signal of 1 unit.
0 件のコメント
回答 (1 件)
Gayathri
2024 年 9 月 27 日
編集済み: Gayathri
2024 年 9 月 27 日
I understand that you want to create a cosine wave with variable frequency and the output is stuck at 1. This is because “frequency” and “time” in the model are integers, and hence, “2*pi*f*t” is an integer multiple of “2*pi”. Therefore, the cosine output is always 1.
You can change the below mentioned code from,
y=cos(2 * pi * f* t);
to
y=cos(2 * pi * f* t / 10000);
This will ensure that arguments are not always integer multiple of “2*pi”. We can replace “10000” with any constant value which will make the arguments not a multiple of “2*pi”. Other way would be to make “frequency” and “time” to be non-integers.
Hope you find this information helpful.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Outputs についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!