0
$\begingroup$

I typed a code for showing a plane and a line, and solve a system, but I can´t show the intersection, because I don´t know.

Here is a minimal working example for understanding my problem ( the real problem is here http://bit.ly/1SNxWJH )

In this code I would like to show the solution of the system for the unknows (x,y): a x + b y == c AND d x + e y == f and plot it

at everytime, So if I move the slider of a,b,c,d,e,f I would like to view/show the point (x,y) that is the solution of hte system

Manipulate[
 s = Solve[a x + b y == c && d x + e y == f];
 ListPlot[{s[[1, 1, 2]], s[[1, 2, 2]]}],
 Style[s, Bold],

 {a, 1, 10},
 {b, 2, 10},
 {c, 3, 10},
 {d, 2, 10},
 {e, 5, 10},
 {f, 8, 10}
 ]

I tried using Dynamic@ and DynamicModule, but I have not a good result.

$\endgroup$
3
  • $\begingroup$ Do you want to solve the linear system for x and y? What do you wish to plot? $\endgroup$
    – bill s
    Nov 20, 2015 at 23:10
  • $\begingroup$ @bill-s .... I want to plot the solution $\endgroup$
    – Mika Ike
    Nov 20, 2015 at 23:12
  • $\begingroup$ Mika, I'm afraid that I still don't understand. Could you explain exactly you consider to be "the solution" here? Have you seen the structure of the result returned by your Solve expression, and is that really what you wanted? $\endgroup$
    – MarcoB
    Nov 20, 2015 at 23:22

1 Answer 1

2
$\begingroup$
Manipulate[
 Module[{soln, pt},
  soln = Solve[
     a x + b y == c && d x + e y == f,
     {x, y}][[1]];
  Column[{
    StringForm["Intersection of lines: ``", soln],
    pt = {x, y} /. soln;
    ContourPlot[{a x + b y == c, d x + e y == f},
     {x, -10, 10}, {y, -10, 10},
     Axes -> True,
     Epilog -> If[Length[pt] > 0,
       {Red, AbsolutePointSize[4],
        Tooltip[Point[pt], pt]}, {}],
     ImageSize -> Medium]}]],
 Row[{Control[{a, 1, 10, 1, Appearance -> "Labeled"}],
   Control[{b, 2, 10, 1, Appearance -> "Labeled"}]}],
 Row[{Control[{c, 3, 10, 1, Appearance -> "Labeled"}],
   Control[{d, 2, 10, 1, Appearance -> "Labeled"}]}],
 Row[{Control[{e, 5, 10, 1, Appearance -> "Labeled"}],
   Control[{f, 8, 10, 1, Appearance -> "Labeled"}]}]]

enter image description here

$\endgroup$
5
  • $\begingroup$ and How could I customize the TEXT in the Label, Supose that I want to view "SLOPE" instead a, or "RADIUS" instead b. I´m not used to use Control. I must learn. Thank you. $\endgroup$
    – Mika Ike
    Nov 21, 2015 at 6:12
  • 1
    $\begingroup$ @MikaIke - as shown in the documentation -- just add a label, e.g., Control[{{a, 1, "SLOPE"}, 1, 10, 1, Appearance -> "Labeled"}] $\endgroup$
    – Bob Hanlon
    Nov 21, 2015 at 6:30
  • $\begingroup$ thank you. I looked for that, but I can´t view in the Help: iestrada.eu/snapshots/snap04hghg7.jpg $\endgroup$
    – Mika Ike
    Nov 21, 2015 at 6:33
  • 1
    $\begingroup$ @MikaIke - look at the next to last entry in the table: {{u, Subscript[u, init], Subscript[u, lbl]}, ...} include label Subscript[u, lbl] $\endgroup$
    – Bob Hanlon
    Nov 21, 2015 at 6:40
  • $\begingroup$ You´re right, thank you very much! for helping and instructing me. $\endgroup$
    – Mika Ike
    Nov 21, 2015 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.