You are on page 1of 2

%simulation of standard waveforms

clc;close all; clear all;


n=input('enter the number of waves');
m=input('enter the width of each half period\peak value');
choice=menu('menu','square wave','triangular wave',.....
'trapezoidal wave');
if(choice==1)
%option1
x=[];
t=m.*ones(1,12);
for ii=0:m-1,
x=[x,t,-t];
end
plot(x);
axis([0 250 -(m+1) m+1]);
elseif(choice==2)
TW=[];
T1=0:0.1:m;
T2=m:-0.1:0;
for ii =0:m-1,
TW=[TW,T1,T2];
end
plot(TW);
grid();
xlabel('time');
ylabel('amplitude');
title('triangular wave');
%option2
display('option 2')
else
tp=[];
T1=0:0.1:m;
t=m.*ones(1,12);
T2=m:-0.1:0;
T3=zeros(1,12);
for ii=0:m-1,
tp=[tp,T1,t,T2,T3];
end
plot(tp);
axis([0 700 -1 m+1]);
%option3
display('option 3')
end

You might also like