Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
Emir Dönmez
Emir Dönmez am 5 Jan. 2024
Kommentiert: Hassaan am 8 Jan. 2024
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 ?)

Akzeptierte Antwort

Hassaan
Hassaan am 5 Jan. 2024
% 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
  2 Kommentare
Emir Dönmez
Emir Dönmez am 8 Jan. 2024
I had solved this question after i asked in here but thanks for showing me another solution.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by