I have a query and will appreciate your help.
If we try the code below,
>> for p=-50:50
pp1(c1,c2)=exp(- ( (p-10).^2 + (q-9).^2) /2) + exp(- ( (p+20).^2 + (q-30).^2) /2);
you can see that the figure(matrix Po) has two peaks(maxima), stating that there are two targets, one at (10,9) and another at (-20,30).
If there is only one target(peak), I used [a,b]=find(Po==max(max(Po))), to find the locations (i,j) at the peak.
But in the above code, we have two peaks. Can you help me to find the
1. No of peaks(estimate no of targets)
2. Find the location of the peaks(i,j)
[Information merged from duplicate Question]
I have a simple query, which was unanswered a few days ago. I am re-posting because I need a hint urgently. Please do not direct me to my previous post. It is not quite complete.
You can copy this code and see the result.
s1 = [5 4 0.5 -0.64]';
s2 = [0 -3.9 -0.5 -0.64]';
Sa = [-40:0.2:40];
Sb = [-40:0.2:40];
L = length(Sa);
m = zeros(L,L);
Pr = 2*ones(L,L);
Pr = Pr / sum(sum(Pr));
x1 = [s1(1);s1(2)] + sqrt(R)*randn(2,1);
x2 = [s2(1);s2(2)] + sqrt(R)*randn(2,1);
for i = 1: length(Pr)
for j = 1: length(Pr)
m(i,j) = (1/sqrt(2*pi)) * (exp(-((Sa(i)-x1(1)).^2 + (Sb(j)-x1(2)).^2)/2) + exp(-((Sa(i)-x2(1)).^2 + (Sb(j)-x2(2)).^2)/2));
m(i,j) = m(i,j) * Pr(i,j);
Po = m/sum(sum(m));
[a,b] = find(Po==max(max(Po)));
Sest = [Sa(a);Sb(b)];
The matrix(surfing of the matrix) 'Po', will result in two peaks at the (s1(1),s1(2)) and (s2(1),s2(2)), show that there are two targets. If I had one peak, a,b would collect it and Sest would collect the location on the grid.
But I am unable to figure out how to find two peaks instead. So the last two statements do not hold now.
I look forward for suggestions on
1. finding the number of peaks(2 in this case)
2. finding the location on grid(Sest in this case) (Sa,Sb)
Will appreciate your help!