This is my first post on this site. Also, I'm new to Mathematica.
I'm trying to solve my first problem with Mathematica. It's about solving a 2nd order differential equation. I dont have the explicit F[t]
instead I have a list of values for {t, F[t]}
{{0, 1.00799}, {0.1, 1.09268}, {0.2, 1.18921}, {0.3, 1.25086}, {0.4, 1.32473},
{0.5, 1.36879}, {0.6, 1.39813}, {0.7, 1.41114}, {0.8, 1.39531}, {0.9, 1.3986},
{1., 1.39468}}
The equation I want to solve is
n = 5
h = 0.1
i = 0
y[0] = 1
yy[0] = 1
zi[0] = Table[i, {i, {1, 1}}]
T1 = {{0, 1.00799}, {0.1, 1.09268}, {0.2, 1.18921}, {0.3,
1.25086}, {0.4, 1.32473}, {0.5, 1.36879}, {0.6, 1.39813}, {0.7,
1.41114}, {0.8, 1.39531}, {0.9, 1.3986}, {1., 1.39468}}
Tij = Table[T1[[i, 2]], {i, 1, 11}]
ij = Table[T1[[i, 1]], {i, 1, 11}]
F[t_] := {y[t], (Tij[[t + 1]] - 9*yy[t] - 13*y[t])/5}
While[i < n, zi[i + 1] = zi[i] + F[i]*h; y[i + 1] = h + i;
yy[i + 1] = zi[[2]]; i = i + 1]
Cell->ConvertTo->InputForm
(from the menu), then select the cell again and do RIGHT-CLICK (with the mouse),COPY-AS->Plain text
. Then paste the result here again. $\endgroup$zi[[2]]
there, and before you wrotezi[0, 0]
You can't do this.zi[[2]]
is trying to access position 2 in a list. You never allocated a list of this size.zi[2]
is different fromz[[2]]
. You can writez[1000]
without having to allocate anything (this is called indexed variable), but you can't writez[[1000]]
without first allocating the space, as this is an actual list or vector in Matlab talk. $\endgroup$