Code covered by the BSD License  

Highlights from
EC1302 DSP Lab

EC1302 DSP Lab

by

 

These are matlab code for experiments in the course EC1302 DSP Lab.

[t,y]=tri(f,A,D,N)
%[t,y]=tri(f,A,D,N) returns samples for
%                   N cycles of triangular wave of
%                   time period, T (=1/f) secs, amplitude, A units and
%                   duty cycle, D%
function [t,y]=tri(f,A,D,N) 
T=1/f;
P=(D/100)*T;
t1=0:(T/20):P;
t2=P:(T/20):T;
if (D==100)
    t=t1;
    y=[(A/P)*t1];
else
    t=[t1,t2];
    y=[(A/P)*t1,-(A*t2)/(T-P)+(A*T)/(T-P)];
end
      
tapp=[];
yapp=[];
for i=1:N
    tapp=[tapp,t+(i-1)*T];
    yapp=[yapp,y];
end
t=tapp;
y=yapp;
plot(t,y);

Contact us