Say I have a set of differential equations not necessarily in first order form. I would like to build the corresponding state space model. When equations are many and long, it becomes difficult to track how the function changes the variables names. In the documentation an example for labeling state space models is provided. Yet in the example the function does not convert an ODE. Say I have the following ODE system (just an example taken from documentation):
NonlinearStateSpaceModel[m x''[t] + c x'[t] + k[x[t]] x[t] == F[t],
x[t], F[t], x[t], t]
How can I automatically ask Mathematica to label the state space variable such that I can keep trace of the step "functions" used to first orderize the ODE? Note in this case it may be simple, but I'm handling in my real problem 15 ODEs among whom 12 are second order and the remaining are first order.
This is particularly troubling when one want to test a feedback law calculated with one system onto another system.
Update I see Suba's answer works good generally. Yet in my problem I still have an odd behavior I simply can't explain. I'm I getting something wrong? The output clearly should be w1+phi1... why does it show rb1???
UPDATE
I've tried the following. First use the firstorderize[] function described by Michael_E2 here
Options[firstOrderize] = {"NewSymbolGenerator" -> (Unique["y"] &)};
firstOrderize[sys_, vars_, t_, OptionsPattern[]] :=
Module[{fop, newsym, toNewVar},
newsym = OptionValue["NewSymbolGenerator"];
fop = Internal`ProcessEquations`FirstOrderize[sys, {t}, 1, vars];
If[newsym === Automatic,(*don't rename*)
Flatten@fop[[1 ;; 2]],(*rename*)
toNewVar =
With[{newvars = MapIndexed[newsym, fop[[3]], {2}]},
Internal`ProcessEquations`FirstOrderReplace[#, {t}, 1, vars,
newvars] &];
Flatten@{toNewVar[fop[[1]] /. Last[fop]],
Activate[
toNewVar[Inactivate[Evaluate@fop[[2]], Derivative]] /.
toNewVar[fop[[4]]]]}]]
Secondly order the labels with SystemsModelLabels but keep in mind that the function wants in order first the labels of the "step functions" developed first orderizing, then the other labels.
Still something doesn't work out: the column that should contain the input is a null vector. Why???? Plus, it apparently swapped the third equation with the 6th!