Question

I am using NMaximize to obtain values from an NDSolve function:

Flatten[NDSolve[{x''[t] == (F Cos[\[CapitalOmega] t] - 
c x'[t] - (k + \[Delta]kb) x[t] + \[Delta]kb y[t])/m, 
y''[t] == (-c y'[t] - (k + \[Delta]kb) y[t] + \[Delta]kb x[t])/m, 
x'[0] == 0, y'[0] == 0, x[0] == 0, y[0] == 0}, {x[t], y[t]}, {t, 0, 10}]];

NMaximize[{Evaluate[y[t] /. s], 8 < t < 9}, t]

This is the case of a set of coupled, second order, ordinary differential equations (they were derived by a constant rotational speed gyroscope). I need to obtain the maximum of the response function after the transient solution has faded and no longer influences the result.

I am trying to use a For loop to obtain the different maximums achieved for a range of "CapitalOmega", say 80 to 130 in steps of 1/2.

Currently I am getting the result in a form:

{a, {t -> b}}

How could This be placed on a list for all the values of "a" obtained from the For loop? This so they can be plotted using

ListLinePlot[]
Était-ce utile?

La solution

If for each value of CapitalOmega you are getting some {a,{t->b}} from your NDSolve and you just want the list of 'a' values then

Table[First[NDSolve[...],{CapitalOmega,80,130,1/2}]

should do it. The First will extract the 'a' each time and using Table instead of For will put them in a list for you. If my example isn't exactly what your actual code is then you should still be able to use this idea to accomplish what you want.

Note: When I try to paste just your NDSolve[...] into Mathematica I get

NDSolve::ndnum: Encountered non-numerical value for a derivative at t==0.`.

which may be a real problem or may just be because of how you cut and pasted your posting.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top