t = linspace(-10, 10, 1000);
square_wave = @(t, center) double(abs(mod(t - center, 2)) < 1);
wave1 = square_wave(t, 1);
wave2 = square_wave(t, 3);
plot(t, wave1, 'DisplayName', 'Square Wave 1 (centered at t=1)');
plot(t, -wave2, 'DisplayName', 'Square Wave 2 (centered at t=3)');
plot(t, m_t, 'DisplayName', 'Message Function m(t)');
title('Square Waves and Message Function m(t)');
Uses an anonymous function to define the square wave, then calculates the waveforms and the message function. Finally, it plots all the functions on the same graph, with a legend to distinguish them.
------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
Professional Interests
- Technical Services and Consulting
- Embedded Systems | Firmware Developement | Simulations
- Electrical and Electronics Engineering