How do i scale to my axis after fft?
Show older comments
My spectrum is of the correct shape, however i am having difficulty in scaling correctly to the frequency domain for the correct frequency bins after fft.
I have comment out the lines of my codes that may require addition of insights and knowledge.
clear all;
close all;
clc;
%% Basic Parameters
w = 0.1; %defined as P_0*tau_0/E_sat or E_in
Fs = 100; %Sampling frequency
tau = -3:1/Fs:3; %0.01 = 1/Fs
alpha = 5;
hold on
%% First iteration
G_0 = 1;
x = (1/2)*sqrt(pi)*w*(1 + erf(tau)); %x = U_in(tau)! %error function!
h = -log(1-(1-(1/G_0))*exp(-x)); %h!
G = G_0./(G_0 -(G_0-1)*exp(-x)); %G!
y = exp(-tau.^2).*G; %y = P_in !
y_out = y.*G; %y = P_out!
phi_out = 0.5*alpha.*h; %phi_out (without phase input)!
% h_dot = -y.*(G-1); %h_dot!
signal = ((y.^0.5).*exp(0.5.*h - (1i .* phi_out)));
% nfft = length(signal); %length of time domain signal
% nfft2 = 2^nextpow2(nfft); %length of signal in power of 2 Need help here!
%need help here!
spectrum = fft(signal);
spectrum = fftshift(spectrum);
spectrum = abs(spectrum).^2;
spectrum_max = max(spectrum);
figure(1);
plot(tau,spectrum/spectrum_max,'g--','LineWidth',0.5);
hold on
%% Subsequent Iterations
for G_0 = [10 100 1000]
x = (1/2)*sqrt(pi)*w*(1 + erf(tau)); %x = U_in(tau)! %error function!
h = -log(1-(1-(1/G_0))*exp(-x)); %h!
G = G_0./(G_0 -(G_0-1)*exp(-x)); %G!
y = exp(-tau.^2).*G; %y = P_in !
y_out = y.*G; %y = P_out!
phi_out = 0.5*alpha.*h; %phi_out (without phase input)! how to obtain phaseinput?
% h_dot = -y.*(G-1); %h_dot!
signal = ((y.^0.5).*exp(0.5.*h - (1i .* phi_out)));
spectrum = fft(signal);
spectrum = fftshift(spectrum);
spectrum = abs(spectrum).^2;
spectrum_max = max(spectrum);
figure(1);
plot(tau,spectrum/spectrum_max,'LineWidth',1);
end
%% Plot-labels
xlabel('(v-v_0)tau','FontSize',14);
ylabel('Normalized power','FontSize',14);
set(gca,'FontSize',14); % size of tick marks on both axes
legend('G_0= Input','G_0= 10 dB','G_0= 20 dB','G_0= 30 dB');
grid on
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Signal Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!