How can I plot a square wave in Matlab

2 visualizaciones (últimos 30 días)
Mallouli Marwa
Mallouli Marwa el 30 de Nov. de 2018
Respondida: Star Strider el 30 de Nov. de 2018
Hello
As attached the square wave equation.
How can I plot it ?

Respuesta aceptada

Star Strider
Star Strider el 30 de Nov. de 2018
Try this:
f = 5; % Frequency
N = 16; % Order Of Harmonics
t = linspace(0, 4, 500); % Time Vector
sqwv = @(f,t,n) 4*sum(bsxfun(@rdivide, sin(2*pi*(1:2:N)'*t), (1:2:N)'))/pi;
figure
plot(t, sqwv(f,t,N))
grid

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by