Program to plot the curve for equation y=sin(x)+cos(x) as x varies from 0 to 2*pi
x=0:10:340;
y=sind(x)+cosd(x);
plot
(x,y);
xlabel('angle
in degree');
ylabel('magnitude');
title('curve
for the equation y=sin(x)+cos(x)');
program
to generate two sinusoids and computation of their product
t=0:0.001:0.1;
f1=input('enter
the freq of first sinusoid');
f2=input('enter
the freq of second sinusoid');
y1=sin(2*pi*f1*t);
y2=sin(2*pi*f2*t);
y=y1.*y2;
p1=fft(y1);
p2=fft(y2);
p3=fft(y);
subplot(2,2,1)
plot(y1)
xlabel('time');
ylabel('amplitude');
title('first
sinusoid in time domain');
subplot(2,2,2)
plot(y2)
xlabel('time');
ylabel('amplitude');
title('second
sinusoid in time domain');
subplot(2,2,3)
plot(abs(p1))
xlabel('time');
ylabel('magnitude');
title('first
sinusoid in freq domain');
|
subplot(2,2,4)
plot(abs(p2))
xlabel('time');
ylabel('magnitude');
title('second
sinusoid in freq domain');
figure,subplot(2,1,1)
plot(y1)
xlabel('time');
ylabel('amplitude');
title('product
of two sinusoids in time domain');
subplot(2,1,2)
plot(abs(p3))
xlabel('time');
ylabel('amplitude');
title('product
of two sinusoids in freq domain');
|
No comments:
Post a Comment