Timeline for Using Manipulate with predefined expressions [duplicate]
Current License: CC BY-SA 3.0
25 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 5, 2014 at 20:03 | comment | added | Michael E2 |
@Alberto, btw, I would approach this particular problem with InterpolatingPolynomial : Manipulate[Plot[InterpolatingPolynomial[{{{0}, f0, 0}, {{1}, f1, ff1}}, t], {t, 0, 1}], {{f0, 0}, 0, 1}, {{f1, 1/2}, 0, 1}, {{ff1, 0}, -1, 0}] . I would have answered your related question, but the value of the interpolating polynomial sometimes exceeds 1 , violating a condition of that question.
|
|
Dec 5, 2014 at 20:02 | comment | added | Michael E2 |
Leonid mentioned lexical scoping, which is the issue in your case, too. The explanation is that the symbols f0 etc. do not appear in the literal (lexical), unevaluated RHS f[t] /. sol[[1]] . This is related to SetDelayed in that the substitution of the parameters is done before the RHS is evaluated. Since t is the only parameter appearing in the RHS, it is the only one substituted. Then the RHS is evaluated and global symbols f0 etc. remain. Manipulate by default localizes symbols, so that the f0 in it is different than the global f0 in g[t] .
|
|
Dec 5, 2014 at 18:05 | comment | added | ac1965 | Thanks. The confusing thing here is that I thought I did the proper thing using g[t_, a_, b_] with the parms a,b in (as Leonid suggests in his famous post link) but in this case it was not enough, as Karsten explained | |
Dec 5, 2014 at 15:53 | history | closed | Mr.Wizard | Duplicate of How are parameters evaluated for a Plot in Manipulate | |
Dec 5, 2014 at 15:53 | history | reopened | Mr.Wizard | ||
Dec 5, 2014 at 15:08 | comment | added | Michael E2 |
@Alberto, For people who find variable scoping an unnecessary nightmare visited upon users by CS demons, the solution Manipulate[..., LocalizeVariables -> False] is easier to understand and use than just about anything else. (Those to whom all variables being global is an abomination will shudder.) HTH. :)
|
|
Dec 5, 2014 at 15:00 | comment | added | Michael E2 | Better duplicate: 10604 (dup. 31322). Related: (18820) | |
Dec 5, 2014 at 14:51 | review | Reopen votes | |||
Dec 5, 2014 at 15:56 | |||||
Dec 5, 2014 at 14:35 | history | edited | ac1965 | CC BY-SA 3.0 |
added 348 characters in body
|
Dec 5, 2014 at 14:32 | vote | accept | ac1965 | ||
Dec 5, 2014 at 12:27 | history | closed |
Yves Klett Öskå Hector Michael E2 Kuba |
Duplicate of Why doesn't my Manipulate work? | |
Dec 4, 2014 at 22:54 | answer | added | Karsten7 | timeline score: 2 | |
Dec 4, 2014 at 18:15 | comment | added | ac1965 | Thanks Karsten 7 - Set versus SetDelayed is the issue I will need to understand: please write it as an answer so I can mark it answered and vote for it | |
Dec 4, 2014 at 16:28 | comment | added | Karsten7 |
Or Manipulate[ Plot[g[t, f0, f1, ff1] /. {{f0 -> mf0, f1 -> mf1, ff1 -> mff1}}, {t, 0, 1}], {{mf0, 0}, 0, 1}, {{mf1, 1/2}, 0, 1}, {{mff1, 0}, -1, 0}]
|
|
Dec 4, 2014 at 16:23 | comment | added | Karsten7 |
You can use Set (= ) instead of SetDelayed (:= ): g[t_, f0_, f1_, ff1_] = f[t] /. sol[[1]]
|
|
Dec 4, 2014 at 16:16 | history | edited | Karsten7 | CC BY-SA 3.0 |
deleted 70 characters in body
|
Dec 4, 2014 at 14:06 | history | edited | ac1965 | CC BY-SA 3.0 |
added 566 characters in body
|
Dec 4, 2014 at 13:45 | comment | added | ac1965 | @Bill: thanks, I know that would work, but the case I have would not be trivial to do that way | |
Dec 4, 2014 at 13:39 | comment | added | ac1965 | @Yves: can you explain ? Are you saying I should put Hold[g]? | |
Dec 4, 2014 at 13:36 | comment | added | ac1965 | @dyonis: yes it is similar, because somebody edited the previous question and deleted this part. | |
Dec 4, 2014 at 13:31 | comment | added | bill s |
g[t_, a_, b_] := a + b t; Manipulate[Plot[g[t, a, b], {t, 0, 1}], {a, 0, 1}, {{b, 1/2}, 0, 1}]
|
|
Dec 4, 2014 at 13:29 | review | Close votes | |||
Dec 5, 2014 at 12:27 | |||||
Dec 4, 2014 at 13:11 | comment | added | dionys | This is very similar to your previous question. | |
Dec 4, 2014 at 13:05 | comment | added | Yves Klett |
Control variables will are localized within Manipulate . Have a look at Manipulate[{a, Hold[a]}, {a, 0, 1}] .
|
|
Dec 4, 2014 at 13:02 | history | asked | ac1965 | CC BY-SA 3.0 |