Student Support Forum: 'Piecewise Interpolation Function' topicStudent Support Forum > General > "Piecewise Interpolation Function"

 Help | Reply To Topic
 Author Comment/Response Jarvis 10/29/09 5:23pm I have a For loop that repeats several times. Inside the loop NDSolve is used to solve an ODE, and the EventLocator method is used to determine when the dependent variable reaches zero. After it has been reached, the initial conditions are changed, and the integration stops. I then Append the current NDSolve solution (an interpolation function) to a list. The loop then repeats. Essentially, I want a piecewise solution to the ODE. When the loop is done, I have a list that contains the times that the dependent variable reached zero, and the interpolation functions for each of the time domains. I use this info along with the Piecewise function to construct a piecewise solution. When I plot this solution, I have a line of code that looks like: Plot[{\[Theta][t], \[Theta]'[t]} /. func[[1]], {t, 0, tvec[[-1]]}] This line plots fine, and appears to give the correct solution. But when I try to do something like use Evaluate to determine what the solution is at a given time, I get errors. For Example: Table[\[Theta][t] /. func, {t, 1}] Yields a ton of errors about the rmix being combinations of lists and non-lists, and all I get out is {{\[Theta][1] /. {{\[Theta] -> \!\(\* TagBox[ RowBox[{"InterpolatingFunction", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{"0.`", ",", "0.5919605020070351`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}], False, Editable->False]\)}, False}, \[Theta][1] /. {{\[Theta] -> \!\(\* TagBox[ RowBox[{"InterpolatingFunction", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{"0.5919605020070351`", ",", "1.7758814700802104`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}], False, Editable->False]\)}, True}, \[Theta][1] /. {{\[Theta] -> \!\(\* TagBox[ RowBox[{"InterpolatingFunction", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{"1.7758814700802104`", ",", "2.9598024311953433`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}], False, Editable->False]\)}, True}, \[Theta][1] /. {{\[Theta] -> \!\(\* TagBox[ RowBox[{"InterpolatingFunction", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{"2.9598024311953433`", ",", "4.143723385352431`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}], False, Editable->False]\)}, True}, \[Theta][1] /. {{\[Theta] -> \!\(\* TagBox[ RowBox[{"InterpolatingFunction", "[", RowBox[{ RowBox[{"{", RowBox[{"{", RowBox[{"4.143723385352431`", ",", "5.327644332551468`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}], False, Editable->False]\)}, True}}} What should I do? How can I actually see what a value of the piecewise function is? Thanks, Jarvis URL: ,
 Help | Reply To Topic