How to create and plot square wave on specified "Tau" value

3 次查看(过去 30 天)
Message funciton of m(t) is basically two square wave. My question is how can i create one these square waves ?
(From duality property left square wave's formula become this =>2*sinc((t-1)*2) and then i can plot this equations graph, maybe ?)

采纳的回答

Hassaan
Hassaan 2024-1-5
% Define the time vector from -10 to 10 with 1000 points
t = linspace(-10, 10, 1000);
% Define the square wave function
square_wave = @(t, center) double(abs(mod(t - center, 2)) < 1);
% Create the square waves with different centers
wave1 = square_wave(t, 1);
wave2 = square_wave(t, 3);
% Calculate the message function m(t) as the difference of the two square waves
m_t = wave1 - wave2;
% Plot the square waves and the message function m(t)
figure;
hold on;
plot(t, wave1, 'DisplayName', 'Square Wave 1 (centered at t=1)');
plot(t, -wave2, 'DisplayName', 'Square Wave 2 (centered at t=3)'); % Negative for subtraction
plot(t, m_t, 'DisplayName', 'Message Function m(t)');
hold off;
% Add title and axis labels
title('Square Waves and Message Function m(t)');
xlabel('Time t');
ylabel('Amplitude');
% Add grid and legend
grid on;
legend show;
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

更多回答(0 个)

类别

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

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by