Filter löschen
Filter löschen

How can I plot a square wave in Matlab

2 Ansichten (letzte 30 Tage)
Mallouli Marwa
Mallouli Marwa am 30 Nov. 2018
Beantwortet: Star Strider am 30 Nov. 2018
Hello
As attached the square wave equation.
How can I plot it ?

Akzeptierte Antwort

Star Strider
Star Strider am 30 Nov. 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

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by