PLEASE HELP WITH SCILAB VERSION OF THIS CODE >> x_n = [ones(1,5) zeros(1,23) one
ID: 1716568 • Letter: P
Question
PLEASE HELP WITH SCILAB VERSION OF THIS CODE
>> x_n = [ones(1,5) zeros(1,23) ones(1,4)];
>> for r = 0:31,
>> X_r(r+1) = sum(x_n.*exp(-j*r*2*pi/N_0*n))/32;
>> end
>> subplot (2,1,1); r = n; stem (r,real(X_r),'k');
>> xlable('r'); ylabel('X_r'); axis([0 31 -.1 0.3]);
>> legend('DTFS by direct computation',0);
>> X_r = fft(x_n)/N_0;
>> subplot(2,1,2); stem(r,real(X_r),'k');
>> xlabel('x'); ylabel('X_r'); axis ([0 31 - .1 0.3]);
>> legend('DTFS by FFT',0);
Explanation / Answer
x_n = [ones(1,5) zeros(1,23) ones(1,4)]; %defining the time domain funtion
n= 1:32; % number of samples
N_0=100;%time scale
for r = 0:31,
X_r(r+1) = sum(x_n.*exp(-j*r*(2*pi/N_0).*n))/32; %DTFT
end
subplot (2,1,1); r = n; stem (r,real(X_r),'k'); %plotting
hold on;
xlabel('r'); %xaxis label
ylabel('X_r');
axis([0 31 -.1 0.3]);
legend('DTFS by direct computation',0);
X_r = fft(x_n)/N_0;
subplot(2,1,2); stem(r,real(X_r),'k');
xlabel('x_n');
ylabel('X_r');
legend('DTFS by FFT',0);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.