How to implement boc (m,n) GPS code ca in Matlab? - matlab

GPS code ca fondamentale frenquecy ie Fo=1.023 MHz, if I want to make correlation and PSD of boc signal and it's shifted signal , we make f=10mhz*fo, but what about 5mhz. Knowing that we have a gpscacode.m function and main code to call this function and make operation on its code sequence. My question is how to implement boc (m,n) in matlab to get correlation and PSD ? Where to use the frenquecy "n"?
Note: boc(1,1) and boc (6,1) works cause n=1.023 MHz .

Related

PPG signal diastolic peak detection using matlab

I'm working on PPG signals. and I want to detect some points for feature extraction. but I can't detect the point illustrated in the following figure on my own dataset:
I have tried to use fft as the following code:
clear
clc
close all
%% Data Importation and Extraction
load('testdata.mat');
increment = 1;
x = [1:increment:length(PPG)];
d = deriv2(PPG);
%%
subplot 211
plot(x,PPG);xlim([0 100]);grid on
subplot 212
plot(diff(diff(PPG)));xlim([0 100]);grid on
Here is my own dataset:
https://www.dropbox.com/s/9qmrcxffzwa7z7h/testdata.mat?dl=0
I recently did a coursework on trying to estimate BPM of heart, by analysing every 5 sec. worth of samples. (The input was taken from phone camera, with flash ON)
But I did my implementation in Python, by using peak detection function available in SciPy. (I got decent results with it). Although I'm not sure whether if there is any similar kind of function available in MATLAB.
https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.find_peaks.html
You can use the available parameters to detect relevant +ve peaks accordingly.
A helpful tip: Prominence is the most important parameter out of all the available parameters.

how to seperate a signal into 4 second segment using MATLAB?

I have an ECG signal and I want to separate it 4 second segments. How to do it in MATLAB?
% MATLAB Code
load ('C:\Users\Explorer\Documents\MATLAB\PhysioNet_Database\Malignant_Ventricular_Ectopy_Database\418m.mat');
signal=val(1,:);
plot(signal); xlabel('Time'); ylabel('Voltage');
418m.mat
The signal is downloaded from website of PhysioNet and is of MIT BIH Malignant_Ventricular_Ectopy_Database.
There are two signal in 418m.mat. I just want to separate first one signal.
Also, there is a function buffer() in MATLAB but it is only for equally spaced in time. I don't know whether this signal is equally spaced in time or not.

generating random baseband signal in matlab

How would you use the MATLAB commands conv & randn to generate a random baseband signal of a specified bandwidth in MATLAB?
I have the equation: m=conv(randn(1,9501),ones(1,500))/100, which [supposedly] produces a bandwidth of about 20Hz, but I don't understand how to modify the signal to obtain the desired bandwidth of 10Hz.
I want to apply this signal in QAM and SSB-SC.

Time of Arrival estimation of a signal in Matlab

I want to estimate the time of arrival of GPR echo signals using Music algorithm in matlab, I am using the duality property of Fourier transform.
I am first applying FFT on the obtained signal and then passing these as parameters to pmusic function, i am still getting the result in frequency domain.?
Short Answer: You're using the wrong function here.
As far as I can tell Matlab's pmusic function returns the pseudospectrum of an input signal.
If you click on the pseudospectrum link, you'll see that the pseudospectrum of a signal lives in the frequency domain. In particular, look at the plot:
(from Matlab's documentation: Plotting Pseudospectrum Data)
Notice that the result is in the frequency domain.
Assuming that by GPR you mean Ground Penetrating Radar, then try radar or sonar echo detection approach to estimate the two way transit time.
This can be done and the theory has been published in several papers. See, for example, here:
STAR Channel Estimation in DS-CDMA Systems
That paper describes spatiotemporal estimation (i.e. estimation of both time and direction of arrival), but you can ignore the spatial part and just do temporal estimation if you have a single-antenna receiver.
You probably won't want to use Matlab's pmusic function directly. It's always quicker and easier to write these sorts of functions for yourself, so you know what is actually going on. In the case of MUSIC:
% Get noise subspace (where M is number of signals)
[E, D] = eig(Rxx);
[lambda, idx] = sort(diag(D), 'descend');
E = E(:, idx);
En = E(:,M+1:end);
% [Construct matrix S, whose columns are the vectors to search]
% Calculate MUSIC null spectrum and convert to dB
Z = 10*log10(sum(abs(S'*En).^2, 2));
You can use the Phased array system toolbox of MATLAB if you want to estimate the DOA using different algorithms using a single command. Such as for Root MUSIC it is phased.RootMUSICEstimator phased.ESPRITEstimator.
However as Harry mentioned its easy to write your own function, once you define the signal subspace and receive vector, you can directly apply it in the MUSIC function to find its peaks.
This is another good reference.
http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=1143830

i am trying to write a code to cross correlate a transmitted signal with a received signal to determine the number of samples delay

Cross correlation is to be used to measure distance to an aircraft by transmitting a
known wide-band signal and correlating the transmitted signal with incoming signals
received via the radar reception dish
The transmitted signal x(n) is of length N=512 while the received signal y(n) is of length N=2048.
y(n)=kx(n-d)+w(n); where 'kx(n-d)' is x(n) delayed by d samples and attenuated by a factor k, and w(n) is reception noise.
i am trying to write a MATLAB program to cross correlate x(n) with the y(n) to determine the value of d, the number of samples delay.
And also Determine a suitable sampling frequency if the distance to the aircraft is to be
determined within 50 km to an accuracy of 50 m, given that the transmitted
and received data is travelling at the speed of light.
The easiest way to do this is with the "xcorr" function. This is part of the Signal Processing toolbox for matlab, but should be available for GNU Octave here. I have not checked if the octave script is completely MATLAB compatible.
You can use the xcorr function as:
[correlation,lags] = xcorr(x,y);
The lag value can be found using
delay = lags(find(correlation==max(correlation)))
At the speed of light, the signal will be travelling at 3 x 10^8 m/s, so to have a resolution of 50m, you should be sampling at at least (3e8/50m) = 6MHz. At this sampling rate, each lag will be 1/6000000 second. If you multiply your delay by this value, you get your total time intervel between transmission and reception of the signal. Multiply this time intervel by the speed of light to get your distance.
You can use generalized Cross correlation -Phase transform GCC PHAT
The following is the MATLAB code for it
function time=GCCPHAT_testmode(b1,b2)
b1f=fft(b1);
b2f=fft(b2);
b2fc=conj(b2f);
neuma=(b1f).*(b2fc);
deno=abs((b1f).*(b2fc));
GPHAT=neuma./deno;
GPHATi=ifft(GPHAT);
[maxval ind]= max(GPHATi);
samp=ind
end
we can ignore the 'find' function in matlab, the command could be changed to
delay = lags(correlation==max(correlation))
'xcorr' suits for vectors with long length;
'gcc' prefer frame by frame.
Aj463's comment above is good, indeed GCC-PHAT is better than unweighted correlation for estimating delay of wide-band signals.
I would suggest a small improvement to the code posted above: to add a small value epsilon to the denominator, epsilon -> 0, in order to avoid eventual division by zero.
Thus, I would change the line
deno=abs((b1f).*(b2fc));
to
deno=abs((b1f).*(b2fc)) + epsilon;