Re: Solving equations



"Miroslav Balda" <miroslav.nospam@xxxxxxxx> wrote in message
<g8hvvt$r50$1@xxxxxxxxxxxxxxxxxx>...
"Mazahir " <maz_p5@xxxxxxxxxxx> wrote in message
<g8hni0$klf$1@xxxxxxxxxxxxxxxxxx>...
:
SNIP
:
Hi Mira,

Sorry but I could not understand your solution well. I know
that solving by least square method might be the best option
but can you please describe the solution and the variables
used like d,a,b,z, res, etc.. dxy is the approx. distance
from corners, but distance of what? Also are the values
randomly taken by you?


Also below I am explaining you the problem again in detail,
so that you can get a clear picture.

I have to find the location of a sound source on a 2d plane.
(I am not considering z axis). I have 4 mics the
co-ordinates of which are m1(0,0), m2(0,6), m3(4,6),
m4(4,0).
del12 is the difference between the distance from mic 1 to
the source and from mic 2 to the source.
del12=((time taken to reach 1st mic-time taken to reach 2nd
mic) x v sound i.e. 340m/s)/fs i.e. 44000. Therefore, for a
particular set of readings, the calculated del12 = 0.0848.
Similarly, del13 = 0.9098 and del14 = 0.5937

Now solving the equations below simultaneously using least
square method will give me the point.

del12=sqrt((x1-x)^2+(y1-y)^2)- sqrt((x2-x)^2+(y2-y)^2)
del13=sqrt((x1-x)^2+(y1-y)^2)- sqrt((x3-x)^2+(y3-y)^2)
del14=sqrt((x1-x)^2+(y1-y)^2)- sqrt((x4-x)^2+(y4-y)^2)

Now this is the exact problem which I cant get hang of.

I think 1st solving with just 3 mics and 2 equations will be
good enough to predict the output before going to the 4th
mic.

Also what I know is that such systems can also be solved by
techniques such as multilateration. If yes, would that be
easier?

Please do reply soon.

Thank you,
Mazahir

Hi Mazahir,

Since that you have changed your descriptiom of the problem,
I will not return to the previous example, which was set by
my by random distances, which I chose. The solution of your
problem is as follows:

x = [0,0,4,4];
y = [0,6,6,0];
xy = [x;y];
dij = [0.0848,0.99098,0.5937];

del = @(d) sqrt(d'*d);
res = @(z) [del(xy(:,1)-z) - del(xy(:,2)-z) - dij(1)
del(xy(:,1)-z) - del(xy(:,3)-z) - dij(2)
del(xy(:,1)-z) - del(xy(:,4)-z) - dij(3)];

[XY,ssq,cnt] = LMFnlsq(res,[2;3],'display',1)

test080820

***************************************************************************
itr nfJ SUM(r^2) x dx l
lc

***************************************************************************
0 1 1.3417e+000 2.0000e+000 0.0000e+000

0.0000e+000 1.0000e+000
3.0000e+000 0.0000e+000
1 2 2.6097e-002 2.6290e+000 -6.2904e-001
0.0000e+000 1.0000e+000
3.1136e+000 -1.1355e-001
2 3 2.4987e-002 2.6390e+000 -9.9365e-003
0.0000e+000 1.0000e+000
3.1240e+000 -1.0411e-002
3 4 2.4987e-002 2.6392e+000 -1.9470e-004
0.0000e+000 1.0000e+000
3.1240e+000 -3.6993e-005

4 5 2.4987e-002 2.6392e+000 6.9462e-007
0.0000e+000 1.0000e+000
3.1240e+000 -1.9698e-006
XY =
2.6392
3.1240
ssq =
0.0250
cnt =
4

* xy are coordinates of microphones,
* dij are your calculated differences,
* del is the handle of anonymous function for calculation of
yours sqrt((x1-x)^2 + ....),
* res is the handle to anonymous function that declares
residuals (errors of your equations)
* XY are coordinates of the sound source,
* ssq is a sum of squares of residuals,
* cnt number of calls to res and Jacobian matrix.

You see that ssq is only by approx. 10^2 lower then for the
initial guess. It means that yours delijs are inexact.
Better way would be in taking times of wave approach to
microphones. More over having reading from 4 microphones
could set 6 equations -> residuals and by least squares get
much more accurate coordinates of the source.

I think, that it is all what to say to it.
Hope it helps.

Mira

PS: The time shift makes the communication difficult. Now is
almost 23 o'clock at Pilsen (CZ).


Hi Mira,

You are right. there is something wrong with my time delays
because the point at which i captured the sound is (1,2) and
the ans = (2,3).
Secondly, as the formulas are :
del12=sqrt((x1-x)^2+(y1-y)^2)- sqrt((x2-x)^2+(y2-y)^2)
del13=sqrt((x1-x)^2+(y1-y)^2)- sqrt((x3-x)^2+(y3-y)^2)
del14=sqrt((x1-x)^2+(y1-y)^2)- sqrt((x4-x)^2+(y4-y)^2)

instead of this complicated method, can i make use of least
square method using matrices and the least square formula to
calculate the location:
x= ((A(transpose)*A)^- 1 )A(transpose) * B

http://www.ee.oulu.fi/~mpa/matreng/ematr5_5.htm
http://www.ee.oulu.fi/~mpa/matreng/eem5_5-1.htm

If yes, then please do let me how do i arrange the elements
in the matrices (It is difficult for me to crack because of
the unknown x and the square root).

Thank you.

- Mazahir
.



Relevant Pages

  • Re: Damped least square
    ... (Peter Spellucci) ... >>> Does somebody know the matlab function or code for Damped least square ... >M is close to singular when I use least square method. ...
    (sci.math.num-analysis)
  • Re: Damped least square
    ... (Peter Spellucci) ... >>> Does somebody know the matlab function or code for Damped least square ... >M is close to singular when I use least square method. ...
    (sci.math.num-analysis)
  • Re: Find the equivalent intersection point of multi lines in 3D space
    ... Least square method should work here. ... apply LSM to the sum of square distances ... The sum also hase the same type of expresstion like: ...
    (sci.image.processing)
  • Re: stepwise regression by GENSTAT
    ... a "stepwise regression method". ... mean square in an ANOVA set-up. ... random variation in the residuals. ... in statistics by the Open University. ...
    (sci.stat.math)
  • Re: stepwise regression by GENSTAT
    ... a "stepwise regression method". ... mean square in an ANOVA set-up. ... random variation in the residuals. ... in statistics by the Open University. ...
    (sci.stat.math)

Loading