MATLAB: How do i plot this waves

waves plot

hi im new in matlab and i need to plot the next waves and i have no idea how to start, i tried and the result didnt look good.
the waves :
1. sine wave, Vp=2V, f=1.5kHz, DC=0V
2. triangle wave, Vp=50mV, f=5kHz, DC=0V
3. square wave, Vptp=5V, f=12kHz, DC=2.5V
4. square wave, Vmin=0V, Vmax=5V, f=80kHz, duty cycle=75%
5. sawtooth wave, Vptp=5V, f=10kHz, DC= -3V
thank you for your help ! 🙂

Best Answer

t=0:0.001:10;
%sine wave
sinewave=2*sin(1500*t);
%square wave Vptp=5v DC=2.5V
squarewave1=2.5+2.5*square(12000*t);
%triangle wave
trianglewave=0.25+0.25*sawtooth(5000*t);
%square wave f=80kHz
squarewave2=2.5+2.5*square(80000*t);
%sawtooth wave
sawtoothwave=-3+2.5*sawtooth(10000*t);
plot(t,sinewave)
%same plot command can be applied for any of them, get closer in figures to
%see the waves since their frequencies are high
If you want to see from a broader perspective, increase the increment of t, like 0.1.
Related Question