MATLAB Answers


Make an on-the-fly tunable-frequency periodic signal in Simulink

Asked by Chuong Le on 5 Apr 2017
My question is relating to "Repeating Sequence Interpolated" block in Simulink.
My target is building a signal which is periodically repeated with tunable frequency. As my study, "Repeating Sequence Interpolated" will work.
However, I cannot change the frequency of this block output signal on-the-fly because the block uses fixed parameter (not signal).
I decided to wrote a m file to create my function, then I pass this function to "Repeating Sequence Interpolated" block. As a result, my function is periodically repeated. That's great the frequency can be changed on the workspace, however, I still cannot change the frequency on-the-fly (simulation). I passed t, and ang to "Repeating Sequence Interpolated" block parameter.
if f == 0
t = [0 1]';
ang = [0 0];
T = 1/f;
fs = 44100;
Ts = 1/fs;
t = linspace(0, T, T/Ts + 1)';
sample_per_half_cyc = T/Ts/2 + 1;
u1 = linspace(-pi/2, pi/2, sample_per_half_cyc);
u2 = linspace(pi/2, -pi/2, sample_per_half_cyc);
u2(1) = [];
u = [u1 u2];
dif = length(t) - length(u);
ang = cat(2, u, -pi/2*ones(1,dif));
Can any one show me the way to rebuild this block with a tunable frequency as input signal?


Sign in to comment.

0 Answers