Info
This question is closed. Reopen it to edit or answer.
check my code please
2 views (last 30 days)
Show older comments
clc,close all,clear all
codn=100;
% fc=6e+3;
fs=360;
bode=10;
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
length(x)
u = length(x)
N = 2^nextpow2(u)
delt = 1/fs;
delf = fs/N;
figure(1)
tvec2=(1:length(x2))*delt;
plot(tvec2,x2(1,:)+0.5)
title('orignal baseband')
xlabel('time');
ylabel('amplitude')
ylim([-1 1.5]);
y = fftshift(fft(x2)/N);
z=abs(y);
figure(2)
fvec2=(-length(x2)/2:length(x2)/2-1)*delf;
plot(fvec2,z)
title('FFT')
xlabel('frequency')
ylabel('amplitude')
figure(3)
z=y;
z(abs(fvec2)>50 & abs(fvec2)<=150)=0
plot(fvec2,abs(z))
xlabel('frequency removed from 50 to 150 HZ');
ylabel('amplitude')
figure(4)
zf=fftshift(z)*N;
zifft=ifft(zf)+0.5;
plot(tvec2,abs(zifft))
ylim([-1 1.5])
title('recovered signal')
xlabel('time');
ylabel('amplitude')
I have make correction in my code.Can anyone tell me that my code is now right?,but i have doubt on my fvec2 is it right?.Moreover i have calculated my data rate please check it whether it is right or wrong.
PARAMETERS FOR DATA RATE ARE;
T=10ms
F(signal frequency)=1/T=0.1KHZ
Fs(sampling frequency)=360HZ
bode=10
No.of bits in 1ms=10 bits
No.of bits in 1s=10k bits/sec
data rate will be=10kb/sec
1 Comment
Walter Roberson
on 11 Nov 2019
Can anyone tell me that my code is now right?
No, at the moment you are the only person who is able to do that. At the moment, the purpose of your code is unknown, undocumented, so we could either say "The correct result is defined by whatever the code does because there is no way to contradict that", or we could say "An undocumented program is always incorrect."
Answers (1)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!