2
$\begingroup$

I have the following Table of ODES:

Vector1=Range[-1,1,2/9]

ODEList1=Table[{theta[[i]]'[t]==Vector1[[i]]-K1/n*Sum[Sin[theta[[i]]-theta[[j]]],{j,1,Length[Vector1]}]},{i,1,Length[Vector1]}]

Is there an easy way to solve these with NDSolve?

What I have tried so far is the following:

K1=10;n=10;
System1=NDSolve[ODEList1,Table[Vector1[[i]],{i,1,Length[Vector1]}],{t,0,500}]
$\endgroup$

1 Answer 1

2
$\begingroup$

Change to use indexed variables and add IC

Clear["Global`*"]
Vector1 = Range[-1, 1, 2/9];
depVars = Table[theta[i], {i, 1, Length[Vector1]}]
K1 = 10; n = 10;
ic = Table[theta[i][0] == 0, {i, 1, Length[Vector1]}]
ODEList1 = Table[{theta[i]'[t] == Vector1[[i]] - 
  K1/n*Sum[Sin[theta[i][t] - theta[j][t]], {j, 1, Length[Vector1]}]}, {i,1, Length[Vector1]}];

System1 = NDSolve[{ODEList1, ic}, depVars, {t, 0, 500}]

Mathematica graphics

$\endgroup$
2
  • $\begingroup$ I am curious: what does Clear["Global`*"] do? I have seen this before but do not understand the logic behind it. Thank you! $\endgroup$ Commented Nov 27, 2022 at 21:11
  • 2
    $\begingroup$ @MathIsHard It clears all variables from global context. Good idea to use it before starting new code. You could also restart the kernel. They are not exactly the same. Restarting the kernel really cleans everything. $\endgroup$ Commented Nov 27, 2022 at 21:14

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.