On 12/17/2016 3:36 PM, vyasa ownby wrote:
> i need help with the code for this. I am ne to Matlab and dont really know how to use the program...
> sampling a continuous time signal and plotting the results.
> The generic cosine wave is a continuous time signal and is given as:
> s(t) = A*cos(2pi*f*t +y )
> where A is the amplitude, f is the frequency (Hz), and
> is the phase shift.
> simulate and plot the sampling of three cosine waves with
> amplitudes A = 1; A = 2; A = 4,
> frequencies f = 2; f = 1; f = 0:1,
> phase = 0; = pi/2, = pi/4 respectively. Setting sampling rate to
> 0.01s, the duration of the sampling to 10s, and clip any sample above +3 and below -3.
> The plot should have time as the x-axis (0s-10s) and the
>sampled wave as the y axis (set bounds to -4 to +4) .
% HW assignment December 17, 2016
% Completed used Matlab 2016a. Did it all by myself
s=@(t,A,f,phase_shift) A*cos(2*pi*f*t +phase_shift);
ts = 0.01;
T = 10;
t = 0:ts:T;
A = [1,2,4];
f = [2,1,0.1];
phase_shift = [0,pi/2,pi/4];
y = s(t,A(i),f(i),phase_shift(i)); %sample
y(y>3) = 3; %clip
y(y<-3) = -3;