Sinusoidal signal with variable instantaneous frequency
Mostrar comentarios más antiguos
Below is a simple matlab code that generates a sinusoidal signal with user specified no of cycles. How do i change this such that each cycle has different instantaneous frequency? For example, if i have 10 cycles, then there should be 10 random frequencies in total where each cycle has different frequency.
clc
clear
f1=120;
fs=f1/60; %sampling frequency depends on f1
no_of_cycles=10;
f=no_of_cycles/60; %Frequency of sinusoid
duration=1;%%duration of the sinusoidal signal in minutes
A=1;
t=1/fs:1/fs:duration*no_of_cycles*1/f; %time index
y1=A*sin(2*pi*f*t);%%simulated sinusoidal signal
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 12 de Jun. de 2017
Figure out how many samples there are per "cycle" for the purpose of your "10 cycles". The last time for each cycle should end 1 sample before the next full cycle boundary. So for example 10 samples per "cycle" should correspond to relative times 0, 1/10, 2/10, 3/10, 4/10, 5/10, 6/10, 7/10, 8/10, 9/10, and should not go all the way to 1 (which would be 11 samples). If you end up using linspace along the way to generate N points, then use linspace(first_time, last_time, N+1 ) and then throw away the last sample.
Now, generate the list of instantaneous frequencies for each cycle. You should probably limit those to being no more than 1/2 the sampling frequency, to avoid aliasing.
instant_frequency_for_cycle = fs/2 * rand(1, no_of_cycles)
Now replicate each of those by the number of samples per cycle:
f = reshape( repmat( instant_frequency_for_cycle(:), 1, samples_per_cycle ), 1, [])
or if you have a sufficiently new MATLAB,
f = repelem( instant_frequency_for_cycle, samples_per_cycle )
or in any version you can use
f = kron(instant_frequency_for_cycle, ones(1, samples_per_cycle) )
After that it is a simple modification to what you had:
y1 = A * sin(2*pi*f.*t); %%simulated sinusoidal signal
the f*t got changed to f.*t . With f and t being the same length, this gives an instant frequency to every sample.
3 comentarios
1.
Mr Roberson answer only works when
samples_per_cycle=12
for any other value of samples_per_cycle different than 12 the last line returns mismatch error.
2.
Also, not constraining the frequency deviation to a small value compared to the carrier frequency loses some of the good properties of FM, like superior SNR compared to AM, following y1 with Walter's lines
.

.
because with Walter's lines the amplitude is no longer constant, it may leak FM into AM, which may not be desirable if you are trying to conceal the information in the carrier phase only.
I have abridged some of the FM key components explained in
as follow:

Sowmya MR
el 12 de Jun. de 2017
Walter Roberson
el 12 de Jun. de 2017
John, you missed my "With f and t being the same length". My outline does not care about the 120 of the original code. I did not assume that "cycle" for the purpose of "10 cycles" corresponds to "hertz".
Categorías
Más información sobre Measurements and Feature Extraction en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



