How can I plot a square wave centered around the Y-axis in MATLAB?

Technical Source
1 min readMar 17, 2021

--

I want to plot a square wave centered around the Y-axis.

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

The following code sample plots a square wave with an amplitude of 1 between -0.5 to +0.5 and 0 else where.

t = -0.5:0.01:0.5;y = square(2*pi*.25*t,100);plot(t,y)tl = -1:0.01:-0.5;yl = square(0*pi*.25*tl,0);tr = 0.5:0.01:1;yr = square(0*pi*.25*tl,0);tg = [tl t tr];yg = [yl y yr];plot(tg,yg)

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet