2
$\begingroup$

Say I have a bunch of equations between variables e.g. h=bcd, i=hce, j=ihbd, k=jhc and I want to do a plot between any two of them, is there an easier way than just rearranging by hand and then plugging into Mathematica? I have tried using Dynamic[] but I think that only works in a sequence rather than all at once?

Panel[Grid[{{Style["Inputs", Bold], SpanFromLeft}, {"a:", 
InputField[Dynamic[a]]},
{"b:", InputField[Dynamic[b]]},
{"c:", InputField[Dynamic[c]]},
{"d:", InputField[Dynamic[d]]},
{"e:", InputField[Dynamic[e]]},
{"f", InputField[Dynamic[f]]},
{"g", InputField[Dynamic[g]]}
}]]


Dynamic[h = bcd]

Dynamic[i = hce]

Dynamic[j = ihbd]

Dynamic[k = jhc]

Plot[k[i], {i, 0, 1}]

Thanks in advance for any help

$\endgroup$
  • 1
    $\begingroup$ Hi Pigeon, Welcome to Mathematica.SE. Could you be more specific in your question? Please share the code you are working on, including the real equation and a the expected output. Only good questions are likely to get great answers. Please edit your question to improve it. Also consider taking the tour. $\endgroup$ – rhermans Nov 22 '14 at 11:53
  • $\begingroup$ There are things to do after your question is answered. Most importantly, if the answer fails to see your need, then please edit or comment on your question to clarify. You may want stay vigilant some time after you get the first answer as its is likely that the best approaches may come later improving over a previous reply. Wait a few hours before voting or accepting $\endgroup$ – rhermans Nov 22 '14 at 12:48
  • $\begingroup$ Once you gain enough reputation by making good questions you will be able to vote up and down both questions and answers.The credibility of the system is based on the reputation gained by users sharing their knowledge. As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – rhermans Nov 22 '14 at 12:49
3
$\begingroup$

For a start I think you may need to use SetDelayed (:=) instead of Set (=).

Then be careful with the spaces, a b c (the product of three different variables) is not the same as abc (a single variable).

Then porbably you want something like this:

ClearAll[a, b, c, d, e, f, g, h, i, j, k]

Panel[Grid[{{Style["Inputs", Bold], SpanFromLeft}, {"a:", 
    InputField[Dynamic[a]]}, {"b:", InputField[Dynamic[b]]}, {"c:", 
    InputField[Dynamic[c]]}, {"d:", InputField[Dynamic[d]]}, {"e:", 
    InputField[Dynamic[e]]}, {"f", InputField[Dynamic[f]]}, {"g", 
    InputField[Dynamic[g]]}}]]

h := b c d
i := h c e
j := i h b d
k := j h c

Dynamic[Plot[k, {i, 0, 1}]]

Mathematica graphics

But I'm failing to see the point of all this. Probably you are looking for something like Manipulate?

$\endgroup$
  • $\begingroup$ Thanks I will try this now! :) I have a 7 or 8 classical mechanics relationships and I wanted to see how the variables related without having to rearrange every time. $\endgroup$ – Pigeon Nov 22 '14 at 12:41
  • $\begingroup$ I can't seem to get it to plot anything. Surely this is a common thing people want to do? Reply if you have a suggestion, thanks. $\endgroup$ – Pigeon Nov 22 '14 at 13:19
  • $\begingroup$ @Pigeon, I don't understand what can't you plot nor what do you think "is a common thing people want to do". By the way, you accepted my answer too hastily, discouraging people to provide alternative solutions. There is no offence if you un-accept it. In te future wait 1 day. $\endgroup$ – rhermans Nov 22 '14 at 14:28
  • $\begingroup$ The delayed assignments do exactly what I wanted, I was just very new. Thank you. $\endgroup$ – Pigeon Dec 4 '14 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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