time domain and frequency domain

조회 수: 1 (최근 30일)
imran khan
imran khan 2019년 10월 31일
댓글: imran khan 2019년 10월 31일
Dear fellows,i am facing problem in my code below.Problem is that signal in time domain does not give me correct value of N,i mean value of N should be like 2^N.Please anyone can solve this issue,and also bit confuse to calculate by data rate,frequency and time(tvec) is in second or milisecond or microsecond.I am not so much good in these things thanks in advance.Please do not change value of tvec(0-0.1).
OR
If anyone has code wich is similar to my results in time domain and frequency domain then please share it to me.
clc,close all,clear all
codn=100;
fs=36000;
bode=1000;
code=round(rand(1,codn));
code_len=round(1/bode/(1/fs))
for ii=1:codn
x((ii-1)*code_len+1:code_len*ii)=code(ii)
end
x2 = x-(1/2) % get rid of most of the dc peak
% set up time and frequency arrays
N = length(x)
delt = 1/fs;
delf = fs/N
tvec = (1:N)*delt
fvec = (-N/2:N/2-1)*delf ; % shifted frequency array
figure(1)
plot(tvec,x2(1,:)+0.5)
title('orignal baseband')
xlabel('time');
ylabel('amplitude')
ylim([-1 1.5]);
pic1.jpg
y = fftshift(fft(x2)/N);
z=abs(y);
figure(2)
plot(fvec,abs(y))
title('FFT')
xlabel('frequency')
ylabel('amplitude')
pic2.jpg

답변 (1개)

Daniel M
Daniel M 2019년 10월 31일
Code looks fine to me. Not sure what you mean by N being 2^N. The only thing I would tweak is setting
tvec = (0:N-1)*delt;
As for your units of fvec and tvec, they are all based off of fs. If that is in Hz then fvec is in Hz and tvec is in seconds.
  댓글 수: 5
Daniel M
Daniel M 2019년 10월 31일
I'm talking about the several other questions you have posted. Myself and others have given you plenty of advice that you have not implemented, or have given feedback on. In this particular question you don't even specify what you want. I get the feeling that you don't know what you want. If you did, you would be able to explain it properly.
imran khan
imran khan 2019년 10월 31일
ok take care

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Frequency-Domain Analysis에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by