I want to Re-write the below Mat lab code but in frequency domain: %time domain
ID: 2081193 • Letter: I
Question
I want to Re-write the below Mat lab code but in frequency domain:
%time domain
t=0:0.001:10;
m=a*sin(2*pi*1*t);
c=b*sin(2*pi*1*t);
y=((1+m).*c);
subplot(4,1,1)
plot(t,y)
title('figure 1 ');
t=0:0.001:10;
a=0.5;
b=1;
m=a*sin(2*pi*0.5*t);
c=b*sin(2*pi*10*t);
y=((1+m).*c);
subplot(4,1,2)
plot(t,y)
title('figure 2 ');
t=0:0.001:10;
a=1;
b=1;
m=a*sin(2*pi*0.5*t);
c=b*sin(2*pi*10*t);
y=((1+m).*c);
subplot(4,1,3)
plot(t,y)
title('figure 3 ');
t=0:0.001:10;
a=2;
b=1;
m=a*sin(2*pi*0.5*t);
c=b*sin(2*pi*10*t);
y=((1+m).*c);
subplot(4,1,4)
plot(t,y);
title('figure 4 ');
Explanation / Answer
%time domain
t=0:0.001:10;
a=0.5; % since this wasnt mentioned in the original code, I have assumes certain values
b=1; % also not mentioned in the code
m=a*sin(2*pi*1*t); %1 Hz
c=b*sin(2*pi*1*t); % 1 Hz
y=((1+m).*c); % 1Hz signal and 2 Hz signal
y_freq1=fft(y);
subplot(4,1,1)
plot(t,y)
title('figure 1 ');
t=0:0.001:10;
a=0.5;
b=1;
m=a*sin(2*pi*0.5*t);
c=b*sin(2*pi*10*t);
y=((1+m).*c);
y_freq2=fft(y);
subplot(4,1,2)
plot(t,y)
title('figure 2 ');
t=0:0.001:10;
a=1;
b=1;
m=a*sin(2*pi*0.5*t);
c=b*sin(2*pi*10*t);
y=((1+m).*c);
y_freq3=fft(y);
subplot(4,1,3)
plot(t,y)
title('figure 3 ');
t=0:0.001:10;
datapoints = length(t);
a=2;
b=1;
m=a*sin(2*pi*0.5*t);
c=b*sin(2*pi*10*t);
y=((1+m).*c);
y_freq4=fft(y, datapoints)/datapoints;
fs=datapoints/10;
f = fs/2*linspace(0,1,datapoints/2+1);
subplot(4,1,4)
plot(t,y);
title('figure 4 ');
figure;
subplot(4,1,1)
plot(f,2*abs(y_freq1(1:datapoints/2+1)));
title('figure 1 ');
subplot(4,1,2)
plot(f,2*abs(y_freq2(1:datapoints/2+1)));
title('figure 2 ');
subplot(4,1,3)
plot(f,2*abs(y_freq3(1:datapoints/2+1)));
title('figure 3 ');
subplot(4,1,4)
plot(f,2*abs(y_freq4(1:datapoints/2+1)));
title('figure 4 ');
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.