How to generate square wave in matlab with frequency,​amplitude,​voltage offset,dutycycle?

498 views (last 30 days)
Hi, I want to generate square wave with frequeency=10/200e-6,amplitude=3.3,voltageoffset=0 and duty cycle=50. can anyone help me with this. Thank you.

Accepted Answer

Birdman
Birdman on 24 Jan 2018
Edited: Birdman on 24 Jan 2018
There is square function for it to be used. Consider the following approach:
freq=10/200;
offset=0;
amp=3.3;
duty=50;
t=0:0.01:100;%100 seconds
sq_wav=offset+amp*square(2*pi*freq.*t,duty);
plot(t,sq_wav)
  5 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!