Ata_sa16
Full Member level 6
- Joined
- Mar 29, 2016
- Messages
- 343
- Helped
- 59
- Reputation
- 118
- Reaction score
- 58
- Trophy points
- 28
- Location
- Milky Way Galaxy, 179° 56′ 39.4″
- Activity points
- 2,221
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
p=[randi([0 1],1,100)]
Fs = 1000;
T=1/Fs
t = 0:T:99*T;
x = interp1(t,p);
plot(t,x);
Fs = 1e9;
T=1/Fs
t = 0:T:(10*4e-6);
pulsewidth = (1e-6)
pulseperiods = [0:50]*3e-6;
x = pulstran(t,pulseperiods,'rectpuls',pulsewidth);
L=40001;
subplot(2,1,1)
plot(t,x);
NFFT = 2048;
X = fftshift(fft(x,NFFT)); %FFT with FFTshift for both negative & positive frequencies
f = Fs*(-NFFT/2:NFFT/2-1)/NFFT; %Frequency Vector
subplot(2,1,2)
plot(f,abs(X)/(L),'r');
title('Magnitude of FFT');
xlabel('Frequency (Hz)')
ylabel('Magnitude |X(f)|');
close all, clear all
set(0, 'language', 'english')
set(gcf, 'numbertitle', 'off')
set(gcf, 'MenuBar', 'none')
set(gcf, 'name', mfilename)
% p = [randi([0 1], 1, 100)]
% Fs = 1000;
% T = 1 / Fs
% t = 0:T:99*T;
% x = interp1(t, p);
% plot(t, x);
x0 = 1:40;
y0 = int32( randn( size(x0) ) >= 0.0 );
OverSamples = 10;
x1 = 1:OverSamples*x0(end);
ix = fix((x1-1)/OverSamples) + 1;
y1 = y0(ix);
plot(x1, y1, 'color', 'g', 'LineWidth', 2)
grid on
Fs = 1e9;
T=1/Fs
t = 0:T:(10*4e-6);
pulsewidth = (1e-6)
pulseperiods = [0:50]*3e-6;
x = 1*pulstran(t,pulseperiods,'rectpuls',pulsewidth);
L=40001;
fc=10e6;
c=sin(2*3.14*fc*t);
y=x.*c;
subplot(5,1,1)
plot(t,x);
subplot(5,1,2)
plot(t,c);
subplot(5,1,3)
plot(t,y);
NFFT = 2048;
X = fftshift(fft(x,NFFT)); %FFT with FFTshift for both negative & positive frequencies
f = Fs*(-NFFT/2:NFFT/2-1)/NFFT; %Frequency Vector
subplot(5,1,4)
plot(f,abs(X)/(L),'r');
title('Magnitude of FFT');
xlabel('Frequency (Hz)')
ylabel('Magnitude |X(f)|');
%
X2 = fftshift(fft(y,NFFT)); %FFT with FFTshift for both negative & positive frequencies
f = Fs*(-NFFT/2:NFFT/2-1)/NFFT; %Frequency Vector
subplot(5,1,5)
plot(f,abs(X2)/(L),'r');
title('Magnitude of FFT');