I am trying to plot a stepped FM pulse waveform with a LFM chirp added on each step. I have used the equation below in Matlab, and want to combine the two. Any idea how to do this?
stepfmwaveform = phased.SteppedFMWaveform('SampleRate',fs,'PulseWidth',5/bw,'PRF',prf,'NumSteps',5,'FrequencyStep',bw/5,'NumPulses',5)
and
lfmwaveform = phased.LinearFMWaveform('SampleRate',fs,'SweepBandwidth',bw,'PRF',prf,'PulseWidth',5/bw)
Related
I am having the following issue. I am trying to analyse the input and output signal of my filter using fft. However, I am not sure if my fft is correct. My input signal is the product of a sawtooth and sine waveforms both with frequencies 6kHz and 32kHz, respectively. Both individual signals have an amplitude of 1 before being multiplied.
Depending on my time values I get different result for my fft plots. If I use values of time spaced out by the period of my sampling frequency, I get a "nice" looking graph with clear peaks as you would expect in a Fourier Transform (see Fig.1). However, if I use values of time spaced out by the period of the signal being sampled, the graph has more frequency components (see Fig. 2). I really don't know which graph is correctly displays my FFT. Also I have the problem that I used an online tutorial to achieve my FFT but I do not understand why the guy did what he did in his code which I do not understand. However, if I plot the absolute values of FFT, I get graphs with similar shapes but the amplitudes jump up to 30 or 40 more (see Fig. 3 and 4). Also for Fig.2 why is there a small wiggle at the start of the filtered signal (time domain) vs time ? Please your help in performing FFT accurately would be of great help. Thanks.
Figures are in Google Drive since website won't allow me to upload more than 1 file:
Fig. 1: https://drive.google.com/file/d/1XHc4jJfMudVOd2E8cluDB4Z8PvfKGsbt/view
Fig. 2: https://drive.google.com/file/d/1pOUhSTSFRwwrKVrwYEa-jYoahqGiYxMA/view
Fig. 3: https://drive.google.com/file/d/10346ttMYZN_Ur_WuwqvbGchYbqmQ6l1F/view
Fig. 4: https://drive.google.com/file/d/17G_FgZznGPNimwgBmGIvqvvcuRvOh80F/view
%Time values using sampling frequency period.
fsampling = 80000;
tsampling = 0:1/fsampling:5000000*Tsampling;
%Time values using sawtooth frequency period.
fsampling = 80000;
fsawtooth = 6000;
Tsawtooth = (1/fsawtooth);
tsawtooth = 0:1/fssampling:20*Tsawtooth;
%Piece of code to use FFT that I don't understand.
L0 = length(product);
NFFT0 = 2^nextpow2(L0);
Y0 = fft(product,NFFT0)/L0;
FreqDom0 = fs/2*linspace(0,1,NFFT0/2+1);
plot(FreqDom0, 2*abs(Y0(1:NFFT0/2+1)));
%Performing FFT using just abs.
IPFFT = abs(fft(product));
plot(t, IPFFT);
i'm new in Simulink and I'm using interpreted MATLAB function block to create a gaussian pulse generator.
This is the function:
function y=mono_gauss(t)
fs=20E9; %sample rate-10 times the highest frequency
ts=1/fs; %sample period
t1=.5E-9; %pulse width(0.5 nanoseconds)
x=(t/t1).*(t/t1); %x=(t^2/t1^2)(square of (t/t1);
A=1;
y=(A*(t/t1)-ts).*exp(-x); %first derivative of Gaussian pulsefunction
end
The problem is that the output of the block generate only one pulse and my objective is to generate a train of pulses just like a pulse generator block.
Any solutions ?
You're most likely better off designing your pulse in MATLAB, then using the Repeating Sequence to use it in Simulink.
For instance, in MATLAB
t = 0:0.01:1;
y = normpdf(t,0.5,0.05);
plot(t,y)
Then within Simulink,
I have also changed the step size of the model Solver to be 0.01.
You'll need to play around with various of these parameters to get the exact curve you desire.
I am using the MATLAB function autocorr to determine the autocorrelation of a time series shown on the left. The resulting autocorrelation plot is shown on the right.
However, I would like to have the autocorrelation plotted as a function of time instead of lags because I would like to show how autocorrelation changed over time. How can I do this in MATLAB?
Using;
Time = Lags / Sample_Rate
Then you could do the following;
[acf,lags] = autocorr(y);
figure
plot(lags/fs, acf)
Where y is your input signal and fs is the sample rate.
Okay, I need to apply PSD on my EEG signal.. My current program code is below where y_theta is my data name.
The problem is, I was asked by my lecturer to create another plot using PSD but without changing the amplitude into dB/Hz (which is the y axis)..How can I do that?
length(y_theta)
nfft = 2^nextpow2(length(y_theta));
Fs=128;
Pxx = abs(fft(y_theta,nfft)).^2/length(y_theta)/Fs;
subplot(2,2,2),
plot(Pxx,'DisplayName','Pxx','YDataSource','Pxx');
Hpsd = dspdata.psd(Pxx(1:length(Pxx)/2),'Fs',Fs);
plot(Hpsd);
I'm working on a project that involves looking at the changes in pitch/frequency over time with a wave file (I'm new to MATLAB, but not to programming). I'm able to see the time-amplitude graph and frequency-amplitude (after an FFT) graph, but how would I be able to isolate the frequency and show it at each point in time?
Code:
filename = '/Users/Username/Sample_1.wav'
[y, fs] = wavread(filename);
y = y(:,1);
dt = 1/fs;
t = 0:dt:(length(y)*dt)-dt;
plot(t,y); xlabel('Seconds'); ylabel('Amplitude');
transformed = fft(y);
mag = abs(transformed);
plot(mag);
If you have the Signal Processing Toolbox, then you may find the spectrogram function useful.
If you don't, then you can achieve the same effect manually by calculating FFTs of consecutive (possibly overlapped) windowed segments of your time-domain data, and then plotting the amplitudes.
This is essentially the short-time Fourier transform (STFT).
If you have the Signal Processing Toolbox, spectrogram is the way to go (as Oli Charlesworth mentioned).
If you don't have it, the MATLAB Central File exchange is always a good place to look for something that general.
http://www.mathworks.com/matlabcentral/fileexchange/1553-spectrogram-short-time-ft-log-magnitude
This seems to be a sensible and well working implementation of the spectrogram functionality.