-2
\$\begingroup\$

I noticed that if I use a small sample time of DSP sine wave in matlab, the signal's frequency "accelerates":

This is the signal with a proper sample time:

sine wave

But if I reduce the sample time too much:

Sine wave accelerating frequency

And the effect remains for even lower sample rates:

Sine wave accelerating

Any idea why this is happening? It must be a simulation bug right?

And, how can I fix it? I guess messing around with solver settings will get it right, since the issue has to do with sampling. My current settings are:

solver settings matlab

\$\endgroup\$
5
  • 2
    \$\begingroup\$ Almost certainly aliasing! \$\endgroup\$ Commented May 1, 2022 at 10:32
  • \$\begingroup\$ 2 dislikes are from MATLAB programmers. :D \$\endgroup\$ Commented May 1, 2022 at 10:45
  • \$\begingroup\$ So, have you looked up aliasing? It feels like something you should understand when working with sampled signals! (I'm not a matlab programmer) \$\endgroup\$ Commented May 1, 2022 at 10:46
  • \$\begingroup\$ @MarcusMüller Yeah, I am checking on it. Ill come back with the results \$\endgroup\$ Commented May 1, 2022 at 10:49
  • \$\begingroup\$ Btw this isnt matlab. \$\endgroup\$
    – Miss Mulan
    Commented May 1, 2022 at 15:58

1 Answer 1

3
\$\begingroup\$

Any idea why this is happening?'

Aliasing

how can I fix it?

Always use a sample rate above the Nyquist rate for the frequencies contained in your signal. Preferably by at least a small multiple (called oversampling)

Note: The title of your question is misleading. The problem didn't occur when you made the sampling interval too small. It happened when you made the sampling interval too large (and so the sampling rate or frequency became too small).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.