Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
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 ?)

Respuesta aceptada

Hassaan
Hassaan el 5 de En. de 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 comentarios
Emir Dönmez
Emir Dönmez el 8 de En. de 2024
I had solved this question after i asked in here but thanks for showing me another solution.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by