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

1 次查看(过去 30 天)
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];
else
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));
end
Can any one show me the way to rebuild this block with a tunable frequency as input signal?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Block Libraries 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by