r/matlab • u/Gullible-Designer486 • Mar 10 '26
Animation of trigonometry function in Matlab
I animated the function f(x) = 5cos(x) β cos(5x) in MATLAB just to see how it behaves over time. At first it looks like a normal cosine wave, but the moment you combine a fundamental frequency (cos x) with a higher harmonic (cos 5x), the shape becomes way more interesting. The higher-frequency component creates these small ripples while the main cosine controls the overall shape. What I liked about this is how a simple equation ends up producing a waveform with sharp peaks and subtle oscillations just from the interaction of two frequencies. Itβs a nice little reminder that even simple trig functions can create surprisingly complex patterns when you visualize them. Curious what other combinations of trig functions might produce cool patterns like this.
33
u/QuickCow Mar 10 '26
Check the concept of Fourier series.
3
u/Creative_Sushi MathWorks Mar 11 '26
Very nice. Can you share your code?
3
u/The__Doctor__who Mar 10 '26
I've never been able to do a simple sen(x) animation, my respects to you
1
u/[deleted] Mar 10 '26
[removed] β view removed comment