how to find the sample space of two or more peaks within a power delay profile
1 次查看(过去 30 天)
显示 更早的评论
I have a signal of 1536 samples, as you can see in the image, I have a first ray of power that exceeds the threshold, if we count there are 4 samples until the next ray that exceeds the threshold, I wanted to know if it is possible to program a script that Say there is a ray of power exceeding the threshold, we are going to find if in the next 5 samples there is another ray exceeding the threshold. now if for example in sample 1000 I have another ray exceeding the threshold, the algorithm would have to search in the next 5 samples if there is another ray exceeding the threshold. Thank you so much![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/762001/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/762001/image.png)
4 个评论
Mathieu NOE
2021-10-11
hello
matlab can do everything... is your question about if it's doable or if someone is keen to code it for you ?
giancarlo maldonado cardenas
2021-10-11
hello.
if someone wants to code it for me, any help will be very useful.
thank you
Mathieu NOE
2021-10-12
ok
I'm up for the task , if you have some data file Ican play with
still It's not 100% clear for me which peaks you want to extract. I have more or less understood that maybe that was a 5th ray after the first one (#8 in your plot) that you wanted to identify - or find if tere is one in the five samples after #8
canyou please clarify ?
giancarlo maldonado cardenas
2021-10-12
hello thank you very much for answering, I will explain better.
I am simulating the LTE random access procedure, which consists of 4 steps, in this procedure two or more user computers can choose the same preamble and in step 3 there is a collision because the base station did not detect that two or more user computers they chose the same preamble this is called (multiplicity).
the base station (eNB) periodically reports 64 preambles to the user equipments (UE).
**********************
attached files.
power delay profile.m -> is a vector of 1536 samples and is divided into 64 bins (vertical lines) that simulate the 64 preambles. The peaks show the arrival of the user equipment (UE) towards the base station in a certain time, X axis.
bins.m -> each bin is divided into 24 samples, 24 * 64 = 1536.
This simulates the 64 preambles, therefore in the power delay profile graph the peaks show that there are 2 users who chose the 60 preamble out of the 64 available and transmitted the same preamble, therefore they are within the same bin 60.
Simulation scenario: place a user very close to the base station and another one further away from the base station, then they arrive at the base station at different times.
So far my algorithm manages to detect or identify that two users chose and transmitted the same preamble because they are within the same BIN, and if the peak exceeds a threshold.
Now I need to code an algorithm that identifies that if these peaks that are within the same BIN are separated by at least 4 or 5 or 6 samples, that will be a variable that I choose, for example samplevariable = 5;
So we know that the power delay profile is divided into 64 BINS and each BIN is divided into 24 samples.
************************
algorithm to encode.
Now in the graph of the power delay profile, we can see that there are two users within the same BIN and remembering that each BIN has 24 samples. The first user, that is, the first ray arrives in sample 116 of the 1536 existing samples, then the algorithm would have to start from that point, and say I am going to check if from sample 116, 4 or 5 or 6 samples later there is another peak that exceeds the threshold, we can see in the graph that 5 samples later, that is, in sample 121 there is another peak that exceeds the threshold, then the algorithm would have to recognize as another user and detect the multiplicity of users, which is when two or more users transmit in the same BIN. Now suppose that in another BIN we have the same scenario, for example we have a peak that exceeds the threshold and this peak is located in sample 1000 again the algorithm would start the verification from that point, from sample 1000, 4 or 5 or 6 more samples ahead there is another peak that exceeds the threshold, we are going to suppose that if then the algorithm would consider that there is another user transmitting in the same BIN, and it would show a message "there are two or more users transmitting in the same BIN (multiplicity of users)"
************************
********************
plot the graph
threshold = 0.108599522476302
figure
stem(pdp,'k');xline (bins,'--k');hold on; yline(threshold,'-.r','threshold','LineWidth',1);title('Power profile delay'); legend('PDP','Umbral','Detección','Bin'); grid on
********************
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/765406/image.png)
采纳的回答
Mathieu NOE
2021-10-13
hello again
this would be my suggestion to pic the two highest peaks inside each data bins , which are distant at least by 4 samples
the selected data appears are red diamonds in the 5th plot
threshold = 0.108599522476302;
% sort bins in ascending order
bins = sort(bins);
% search inside a buffer between two bins values
for ci = 1: numel(bins)-1
%select data inside bin
ind = (ceil(max(bins(ci),1)):floor(bins(ci+1)));
data = pdp(ind);
figure(ci)
hold on
stem(ind,data,'k','filled');
yline(threshold,'-.r','threshold','LineWidth',1);
xline(bins(ci),'--k');
xline(bins(ci+1),'--k');
% search for values above threshold
ind_val_ab_th = find(data>threshold);
if ~isempty(ind_val_ab_th)
val_ab_th = data(ind_val_ab_th);
% sort and pick 2 highest peaks
[val_ab_th,b] = sort(val_ab_th,'descend');
ind_val_ab_th = ind_val_ab_th(b);
ind_val_ab_th = ind_val_ab_th(1:2);
val_ab_th = val_ab_th(1:2);
% check x distance between the two selected points
x_dist = abs(ind_val_ab_th(1) - ind_val_ab_th(2));
if x_dist>4
plot(ind(ind_val_ab_th),val_ab_th,'dr');
end
end
end
13 个评论
giancarlo maldonado cardenas
2021-10-13
Hello again.
thank you very much, your algorithm works for some scenarios!
The peaks in the vector of 1536 samples (power delay profile), are generated randomly, this means that it depends on the location of the user within a radius of 790 meters, so from what I could understand from your algorithm it finds the highest peaks, but when the peaks are not the highest the algorithm does not work, as you can see in the attached figure the algorithm should find the sample 1425 and 1431 because they are within the same BIN and are separated by 5 samples, the algorithm Find the highest point which is sample 1449. How could you do in this case?![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/766776/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/766776/image.png)
And I wanted to say that I will need help later, would you like to participate in my research? I will write an article, and if you join the team, your name would be on the article.
thanx again!
Mathieu NOE
2021-10-14
hello
as much as I can, I will try to continue to support you , but I am not sure that my modest contribution is enough to be cited in your work - thanks anyway for the proposal
back to the work : ok I first believed that the first point to pick would be the highest one, but that assumption can be modified of course.
I hope I understand right his time ; the algo has to find the first emerging peak and then look for the next with a distance above 4 (min equal to 5) in the same bin - correct ?
Mathieu NOE
2021-10-14
try this code please
threshold = 0.108599522476302;
% sort bins in ascending order
bins = sort(bins);
% search inside a buffer between two bins values
for ci = 1:numel(bins)-1
%select data inside bin
ind = (ceil(max(bins(ci),1)):floor(bins(ci+1)));
data = pdp(ind);
figure(ci)
hold on
stem(ind,data,'k','filled');
yline(threshold,'-.r','threshold','LineWidth',1);
xline(bins(ci),'--k');
xline(bins(ci+1),'--k');
% search for values above threshold
ind_val_ab_th = find(data>threshold);
if numel(ind_val_ab_th)>1 % we must have at least two values
val_ab_th = data(ind_val_ab_th);
% check x distance between first selected point and remaining
% points (if exist)
ind_first_point = ind_val_ab_th(1);
ind_others_points = ind_val_ab_th(2:end);
x_dist = abs(ind_first_point - ind_others_points);
ind_select = find(x_dist>4); % define min distance between points
if numel(ind_select)>=1 % we must have at least one value (one binome of points)
ind_second_point = ind_others_points(ind_select(1));
ind_two_points = [ind_first_point ind_second_point];
plot(ind(ind_two_points),data(ind_two_points),'dr');
end
end
end
giancarlo maldonado cardenas
2021-10-18
Hello again, I'm sorry I didn't reply these days, I was testing your algorithm in various scenarios and didn't want to steal your time on the weekend.
Returning to work, in a 3-user scenario (figure 1).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/771078/image.png)
Figura 1.
If you run your code, you can see from (figure 2), plot 34th, that the algorithm works only for 2 users, the first ray that exceeds the threshold is at point 805, then the algorithm starts counting 4 samples and detects the second user at position 810, great !!.
Now in the 3-user scenario, the algorithm does not work, as shown in (figure 2), plot 34th, once it detects the second user at position 810, the algorithm would have to reset the counter and start counting again 4 samples from position 810 and detect user 3 at position 815.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/771083/image.png)
Figura 2.
Let's imagine a scenario where there are 4,5 ...... N, users within the same BIN and they are separated by 4 samples, the algorithm would also have to detect them.
Is there a way to modify the code to do this?
Thank you very much in advance !!
**********************
attached files.
pdp3users.mat = vector of 1536 samples
bins3users.mat = vector of 64 samples
threshold = 0.0149397130983473
**********************
Mathieu NOE
2021-10-25
hello
please check this version
now should not be any limit on how many points are detected inside a single bin
I focused on bin # 34 as this is were you show the above plot
so change this line of code for all bins :
for ci = 34; %1:numel(bins)-1
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/777918/image.png)
clc
clearvars
close all
load bins3users.mat
load pdp3users.mat
threshold = 0.0149397130983473
% sort bins in ascending order
bins = sort(bins);
% search inside a buffer between two bins values
for ci = 34; %1:numel(bins)-1
%select data inside bin
ind = (ceil(max(bins(ci),1)):floor(bins(ci+1)));
data = pdp(ind);
figure(ci)
hold on
stem(ind,data,'k','filled');
yline(threshold,'-.r','threshold','LineWidth',1);
xline(bins(ci),'--k');
xline(bins(ci+1),'--k');
% search for values above threshold
ind_val_ab_th = find(data>threshold);
if numel(ind_val_ab_th)>1 % we must have at least two values in one bin
% val_ab_th = data(ind_val_ab_th);
% check x distance between first selected point and remaining
% points (if exist)
ind_all_points = [];
ind_first_point = ind_val_ab_th(1);
ind_all_points = [ind_first_point];
remaining_start_ind = 2;
ind_select_next = remaining_start_ind;
while 1
ind_others_points = ind_val_ab_th(remaining_start_ind:end);
x_dist = abs(ind_all_points(end) - ind_others_points);
ind_select_next = find(x_dist>4); % define min distance between successive points
if ~isempty(ind_select_next)
ind_next_point = ind_others_points(ind_select_next(1));
ind_all_points = [ind_all_points ind_next_point];
remaining_start_ind = find(ind_val_ab_th>ind_next_point);
remaining_start_ind = remaining_start_ind(1);% update loop
else
break
end
end
plot(ind(ind_all_points),data(ind_all_points),'dr');
end
end
giancarlo maldonado cardenas
2021-10-25
Hello my brother!
I was testing your algorithm it seems to work to a certain extent, the only thing I did was change the threshold to threshold = 4.75719e-05. to have more rays above the threshold.
and shows an error on the 17th plot (see figure 1). why?
by the way, now the algorithm is recursive right?
thanks in advance![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/778058/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/778058/image.png)
figure 1
Mathieu NOE
2021-10-26
hello
this is the line that needed a small correction
remaining_start_ind = find(ind_val_ab_th>=ind_next_point); % correction 26/10/21 : ">=" instead of ">"
Full code :
clc
clearvars
close all
load bins3users.mat
load pdp3users.mat
% threshold = 0.0149397130983473;
threshold = 4.75719e-05;
% sort bins in ascending order
bins = sort(bins);
% search inside a buffer between two bins values
for ci = 1:numel(bins)-1
%select data inside bin
ind = (ceil(max(bins(ci),1)):floor(bins(ci+1)));
data = pdp(ind);
figure(ci)
hold on
stem(ind,data,'k','filled');
yline(threshold,'-.r','threshold','LineWidth',1);
xline(bins(ci),'--k');
xline(bins(ci+1),'--k');
% search for values above threshold
ind_val_ab_th = find(data>threshold);
if numel(ind_val_ab_th)>1 % we must have at least two values in one bin
% check x distance between first selected point and remaining
% points (if exist)
ind_all_points = [];
ind_first_point = ind_val_ab_th(1);
ind_all_points = [ind_first_point];
remaining_start_ind = 2;
ind_select_next = remaining_start_ind;
while 1
ind_others_points = ind_val_ab_th(remaining_start_ind:end);
x_dist = abs(ind_all_points(end) - ind_others_points);
ind_select_next = find(x_dist>4); % define min distance between successive points
if ~isempty(ind_select_next)
ind_next_point = ind_others_points(ind_select_next(1));
ind_all_points = [ind_all_points ind_next_point];
remaining_start_ind = find(ind_val_ab_th>=ind_next_point); % correction 26/10/21 : ">=" instead of ">"
remaining_start_ind = remaining_start_ind(1);% update loop
else
break
end
end
plot(ind(ind_all_points),data(ind_all_points),'dr');
end
end
Mathieu NOE
2021-10-26
and to answer your question : by the way, now the algorithm is recursive right?
yes !!
giancarlo maldonado cardenas
2021-10-28
hello again my friend.
I've been testing your algorithm, it's perfect, you're a genius !!
but in this line of code
ind_others_points = ind_val_ab_th (remaining_start_ind: end);
calculates (all) the remaining points.
in the following line of code
x_dist = abs (ind_all_points (end) - ind_others_points);
calculates all the distance of (all) the points.
in the following line of code
ind_select_next = find (x_dist> 4);
defines the minimum distance between (all) points
in the following line of code
ind_next_point = ind_others_points (ind_select_next (1));
select the second point.
for example if you had a million points to calculate, the algorithm would take a long time because it is calculating (all) the points unnecessarily.
Do you think there is a possibility that the algorithm first finds the next point and then calculates the distance between those two points? then find the next point and calculate the distance and so on? instead of calculating (all) the points.
this way it would not consume a lot of memory resources.
And thank you very much, the invitation on the article still stands hehe, and in gratitude you can send me your paypal, I will pay you a coffee.
thanks in advance.
Mathieu NOE
2021-10-28
hello again Giancarlo
I think I can do a simpler code like this - maybe there is even simpler but today that's all my brain could achieve after two very short nights (not for the reasons you're thinking !)
clc
clearvars
close all
load bins3users.mat
load pdp3users.mat
% threshold = 0.0149397130983473;
threshold = 4.75719e-05;
% sort bins in ascending order
bins = sort(bins);
% search inside a buffer between two bins values
for ci = 1:numel(bins)-1
%select data inside bin
ind = (ceil(max(bins(ci),1)):floor(bins(ci+1)));
data = pdp(ind);
figure(ci)
hold on
stem(ind,data,'k','filled');
yline(threshold,'-.r','threshold','LineWidth',1);
xline(bins(ci),'--k');
xline(bins(ci+1),'--k');
% search for values above threshold
ind_val_ab_th = find(data>threshold);
if numel(ind_val_ab_th)>1 % we must have at least two values in one bin
% check x distance between first selected point and remaining
% points (if exist)
ind_all_points = [];
ind_first_point = ind_val_ab_th(1);
ind_all_points = [ind_first_point]; % example : 1 8 13 19 24 for bin 17
ind_next_point = ind_first_point;
for ck = 2:length(ind_val_ab_th)
dist =abs(ind_val_ab_th(ck) - ind_next_point);
if dist>4
ind_next_point = ind_val_ab_th(ck);
ind_all_points = [ind_all_points ind_next_point];
end
end
plot(ind(ind_all_points),data(ind_all_points),'dr');
end
end
giancarlo maldonado cardenas
2021-10-29
Hello again Mathieu, hahahaha it could be for many reasons, right? but it was just what i was thinking haha.
I wanted to thank you for your help now it's perfect !!
Thank you very much, I hope you consider helping me in the next step, if you could leave me how to contact you, so that you can answer my next question in the matlab forum. have a great end of week, hug!
Mathieu NOE
2021-11-2
Hi Giancarlo
I'm gald I could be of some help here
You can always contact me via my author's page on this forum
have a good day !
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Detection, Range and Doppler Estimation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)