I want to solve a system of ODEs in sweeping a parameter $\omega$, and in that final conditions need to be carried for the initial condition for the next value of parameter $\omega$. Also, I want to export the data to Excel sheet. The given answer is useful, but exporting the values seems very difficult. Here, I have written my code.
tmax = 30; X0 = {1, 0.9, 2, 0.5, -1}; X0d = {0, 0, 0, 0, 0}; ω = {0.5, 0.6, 0.7, 0.8, 0.9, 1}; mt = ConstantArray[0, {1000, 6}]; K = 2*IdentityMatrix[5]; i = 1; While[i < 5, K[[i, i + 1]] = -1; i++]; i = 1; While[i < 5, K[[i + 1, i]] = -1; i++] Table[ X[t_] := Table[Subscript[x, i][t], {i, 1, 5}]; Xb[t_] := Subscript[x, 5][t]*Sin[ω [[j]] t]; {s} = NDSolve[ {D[X[t], t, t] + K.X[t] == {Xb[t], 1, Xb[t], 1, Xb[t]} * Sin[t], X[0] == X0, X'[0] == X0d}, X[t], {t, 0, tmax} ]; (*Using Subscript[x,1][t] /. s /. t -> tmax and Updating X0 && X0d*) i = 1; While[ i < 6, X0[[i]] = Subscript[x, i][t] /. s /. t -> tmax; X0d[[i]] = D[Subscript[x, i][t] /. s, t] /. t -> tmax; i++ ]; (* To get the list of all values for perticular Subscript[x,i][t] *) Needs["DifferentialEquations`InterpolatingFunctionAnatomy`"]; xvals = InterpolatingFunctionValuesOnGrid[First[First[s]]]; (* But even for x1 also it is not working *) mt[[1 ;; Length[xvals], j]] = xvals;, {j, 1, 6} ] Export["narhari.xls", {"trials" -> mt}] Here, I am not able to export the list for $x_i$ values and also D[X[t],t]/.t->tmax also not possible.
I am confused among different types of usage of NDSolve.

