Generating a cosine wave with variable frequency where frequency is an output from a lookup table
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Gayathri
am 27 Sep. 2024
Bearbeitet: Gayathri
am 27 Sep. 2024
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 Kommentare
Siehe auch
Kategorien
Mehr zu Outputs finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!