Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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!

share|improve this question
    
Please include the Manipulate code you are trying. –  Mr.Wizard May 13 at 13:23
    
I get FindMinimum::eit: The algorithm does not converge ... Don't you? –  Öskå May 13 at 13:23
    
If P multiplies just a, introducing the new parm will result in a new a.... which is the old one just divided by P .... –  belisarius May 13 at 13:25
    
@Öskå, Yes it gives an error message but in the end the ListLinePlot is accomplished. –  Roberto May 13 at 13:27
    
One usually doesn't like error messages.. :) –  Öskå May 13 at 13:30

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
    
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! –  Roberto May 13 at 15:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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