0
$\begingroup$

I need to Manipulate a ListLinePlot using a parameter P. The problem is that this Curve is a ListLinePlot of a Transpose[{T,B}], in which T is a normal table and B is a list of minima got using FindMinimum in f[x]. This is a simplified code that contains my concern:

f[x_] := (b/a)*x^2 + (x^2/b) Quiet[Xmin = Table[ FindMinimum[{f[x], a >= 1, b >= 1}, {a, b}], {x, 250, 310, 20}]]; T = Table[T, {T, 250, 310, 20}]; B = b /. Take[Xmin, All, {2}] // Flatten; Transpose[{T, B}]; ListLinePlot[Transpose[{T, B}]] 

I'm able to plot this ListLinePlot as it is presented in the code but the idea is to insert a parameter P, multiplying the constant "a", inside of f[x] (P varies from 1 - 50).

When I just put this ListLinePlot correctly inside the Manipulate expression, setting P as a changeable parameter and also insert the parameter P, multiplying the constant "a", the routine is not able to output B and I get a list of errors. I really need B, so, is there any way to Manipulate it?

The Manipulate code that is not working is this:

Manipulate[ListLinePlot[Transpose[{T, B}]], {P, 1, 50}] 

But with this Manipulate code above is evaluated only if I change "a" for "a*P" in the f[x].

Thanks a lot!

$\endgroup$
9
  • $\begingroup$ Please include the Manipulate code you are trying. $\endgroup$ Commented May 13, 2014 at 13:23
  • $\begingroup$ I get FindMinimum::eit: The algorithm does not converge ... Don't you? $\endgroup$ Commented May 13, 2014 at 13:23
  • $\begingroup$ If P multiplies just a, introducing the new parm will result in a new a.... which is the old one just divided by P .... $\endgroup$ Commented May 13, 2014 at 13:25
  • $\begingroup$ @Öskå, Yes it gives an error message but in the end the ListLinePlot is accomplished. $\endgroup$ Commented May 13, 2014 at 13:27
  • $\begingroup$ One usually doesn't like error messages.. :) $\endgroup$ Commented May 13, 2014 at 13:30

1 Answer 1

1
$\begingroup$

This is very slow to update due to the repetitive use of FindMinimum but perhaps it is what you want:

DynamicModule[{f, Xmin, T, B, a, b}, Manipulate[ f[x_] := (b/(a*P))*x^2 + (x^2/b); Xmin = Quiet@Table[FindMinimum[{f[x], a >= 1, b >= 1}, {a, b}], {x, 250, 310, 20}]; T = Range[250, 310, 20]; B = b /. Take[Xmin, All, {2}] // Flatten; ListLinePlot[Transpose[{T, B}]], {P, 1, 50, 1}, TrackedSymbols :> {P} ] ] 

enter image description here

$\endgroup$
1
  • $\begingroup$ thanks so much! It was a really small version of my code. I have encapsulated everything in one manipulate but it is taking ages to evaluate. It works but it takes ages. Thanks again! $\endgroup$ Commented May 13, 2014 at 15:31

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.