Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
solve equation

Subject: solve equation

From: Song Joo

Date: 4 Dec, 2008 23:43:02

Message: 1 of 7

Hi all,
How could I solve these equations in matlab?

a^2-(x3-x2)^2-(y3-y2)^2=0
b^2-(x2-x1)^2-(y2-y1)^2=0

a, b, x1,x3,y1, y3 are known. so basically i am looking for x2 and y2.
solve command does not solve these equations. Does anybody know how to simply do this?

Thanks in advance.

Subject: solve equation

From: Roger Stafford

Date: 5 Dec, 2008 00:48:02

Message: 2 of 7

"Song Joo " <song-lee@northwestern.edu> wrote in message <gh9pu6$7ug$1@fred.mathworks.com>...
> Hi all,
> How could I solve these equations in matlab?
>
> a^2-(x3-x2)^2-(y3-y2)^2=0
> b^2-(x2-x1)^2-(y2-y1)^2=0
>
> a, b, x1,x3,y1, y3 are known. so basically i am looking for x2 and y2.
> solve command does not solve these equations. Does anybody know how to simply do this?
>
> Thanks in advance.

  I would have thought 'solve' could do that problem easily. Did you specify which were to be regarded as the unknowns in your call to it?

  It is also easy to solve it manually. Just subtract one equation from the other, thereby eliminating the x2^2 and y2^2 terms, and leaving an expression that is linear in x2 and y2. You can then solve for one of these in terms of the other. Substituting it in one of the original equations will give a quadratic equation in a single unknown. You will in general find two solutions for it. Then use the above linear expression to find the other unknown.

Roger Stafford

Subject: solve equation

From: Song Joo

Date: 5 Dec, 2008 01:24:01

Message: 3 of 7

I did this way
[x2,y2]=solve('a^2-(x3-x2)^2-(y3-y2)^2=0',' b^2-(x2-x1)^2-(y2-y1)^2=0')
and others are known. but when I excute this command, i don't get the results but just the equations as the output. Other values are known but they varies so if this command works, I would want to keep this way.

Would you recommend anything or did I do something wrong when I use solve command?

Sincerely
SongJoo

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gh9to2$lq4$1@fred.mathworks.com>...
> "Song Joo " <song-lee@northwestern.edu> wrote in message <gh9pu6$7ug$1@fred.mathworks.com>...
> > Hi all,
> > How could I solve these equations in matlab?
> >
> > a^2-(x3-x2)^2-(y3-y2)^2=0
> > b^2-(x2-x1)^2-(y2-y1)^2=0
> >
> > a, b, x1,x3,y1, y3 are known. so basically i am looking for x2 and y2.
> > solve command does not solve these equations. Does anybody know how to simply do this?
> >
> > Thanks in advance.
>
> I would have thought 'solve' could do that problem easily. Did you specify which were to be regarded as the unknowns in your call to it?
>
> It is also easy to solve it manually. Just subtract one equation from the other, thereby eliminating the x2^2 and y2^2 terms, and leaving an expression that is linear in x2 and y2. You can then solve for one of these in terms of the other. Substituting it in one of the original equations will give a quadratic equation in a single unknown. You will in general find two solutions for it. Then use the above linear expression to find the other unknown.
>
> Roger Stafford

Subject: solve equation

From: Roger Stafford

Date: 5 Dec, 2008 01:42:02

Message: 4 of 7

"Song Joo " <song-lee@northwestern.edu> wrote in message <gh9vrh$jim$1@fred.mathworks.com>...
> I did this way
> [x2,y2]=solve('a^2-(x3-x2)^2-(y3-y2)^2=0',' b^2-(x2-x1)^2-(y2-y1)^2=0')
> and others are known. ........
 
  You need to specify what your unknowns are in the 'solve' function. It has no way of determining that 'x2' and 'y2' are to be regarded as the unknowns. See the Matlab guide for the symbolic toolbox.

Roger Stafford

Subject: solve equation

From: Song Joo

Date: 5 Dec, 2008 17:02:02

Message: 5 of 7

I ended up to go back to your other suggestion.-moreless manually solving with one unknown variable. The other question is this,
Then the solution is,
i*(((17*17797387353769591822856140666864759^(1/2))/4503599627370496000 - 1945982880988654689/22517998136852480000)^2 - 289/2500)^(1/2) + 7744119703248663/18014398509481984
 7744119703248663/18014398509481984 - i*(((17*17797387353769591822856140666864759^(1/2))/4503599627370496000 - 1945982880988654689/22517998136852480000)^2 - 289/2500)^(1/2)
 
Which is supposed to be two simple values but i don't know why matlab format gives me these ridiculous numbers as solutions.

When I recopy this value , then it will give me simple solutions as

ans =

    0.6716


ans =

    0.1882

Does anyone know matlab command to simply these complex formats?

Thanks in advance,
SongJoo


"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gha0ta$9lg$1@fred.mathworks.com>...
> "Song Joo " <song-lee@northwestern.edu> wrote in message <gh9vrh$jim$1@fred.mathworks.com>...
> > I did this way
> > [x2,y2]=solve('a^2-(x3-x2)^2-(y3-y2)^2=0',' b^2-(x2-x1)^2-(y2-y1)^2=0')
> > and others are known. ........
>
> You need to specify what your unknowns are in the 'solve' function. It has no way of determining that 'x2' and 'y2' are to be regarded as the unknowns. See the Matlab guide for the symbolic toolbox.
>
> Roger Stafford

Subject: solve equation

From: Joerg Buchholz

Date: 5 Dec, 2008 17:16:02

Message: 6 of 7

"Song Joo " <song-lee@northwestern.edu> wrote in message <ghbmqa$491$1@fred.mathworks.com>...
> I ended up to go back to your other suggestion.-moreless manually solving with one unknown variable. The other question is this,
> Then the solution is,
> i*(((17*17797387353769591822856140666864759^(1/2))/4503599627370496000 - 1945982880988654689/22517998136852480000)^2 - 289/2500)^(1/2) + 7744119703248663/18014398509481984
> 7744119703248663/18014398509481984 - i*(((17*17797387353769591822856140666864759^(1/2))/4503599627370496000 - 1945982880988654689/22517998136852480000)^2 - 289/2500)^(1/2)
>
> Which is supposed to be two simple values but i don't know why matlab format gives me these ridiculous numbers as solutions.
>
> When I recopy this value , then it will give me simple solutions as
>
> ans =
>
> 0.6716
>
>
> ans =
>
> 0.1882
>
> Does anyone know matlab command to simply these complex formats?
>
> Thanks in advance,
> SongJoo

The 'double' command should do the job.

Subject: solve equation

From: Song Joo

Date: 5 Dec, 2008 17:33:02

Message: 7 of 7

Thank you very much!
"Joerg Buchholz" <buchholz@hs-bremen.de> wrote in message <ghbnki$h70$1@fred.mathworks.com>...
> "Song Joo " <song-lee@northwestern.edu> wrote in message <ghbmqa$491$1@fred.mathworks.com>...
> > I ended up to go back to your other suggestion.-moreless manually solving with one unknown variable. The other question is this,
> > Then the solution is,
> > i*(((17*17797387353769591822856140666864759^(1/2))/4503599627370496000 - 1945982880988654689/22517998136852480000)^2 - 289/2500)^(1/2) + 7744119703248663/18014398509481984
> > 7744119703248663/18014398509481984 - i*(((17*17797387353769591822856140666864759^(1/2))/4503599627370496000 - 1945982880988654689/22517998136852480000)^2 - 289/2500)^(1/2)
> >
> > Which is supposed to be two simple values but i don't know why matlab format gives me these ridiculous numbers as solutions.
> >
> > When I recopy this value , then it will give me simple solutions as
> >
> > ans =
> >
> > 0.6716
> >
> >
> > ans =
> >
> > 0.1882
> >
> > Does anyone know matlab command to simply these complex formats?
> >
> > Thanks in advance,
> > SongJoo
>
> The 'double' command should do the job.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us