Suppose I have three differential equations systems, each one of them has 4 equations. I find the 4 solutions of each one, let's call them x,y,z,w. Now, I want to take $x_1$,$x_2$,$x_3$ and put them in an array so I can plot it by letting t vary. This array would be: $$ \alpha(t) = \{x_1(t),x_2(t),x_3(t)\} $$ Then I also want to take $y_i$,$z_i$ and $w_i$ to to the same. If you are curious $\alpha$ would be my curve and then the other is the Frenet tried.

However I am struggling to to this, for alpha I would do this in Mathematica:

alpha[t_] := {x[t] /. Part[solution1[[1]], 1], 
              y[t] /. Part[solution2[[1]], 1], 
              z[t] /. Part[solution3[[1]], 1]}

However It doesn't seem to work, because I then try to plot Alpha like this:

ParametricPlot3D[Evaluate[alpha[t]], {t, 0, 6}]

But I get an empty cube.

Solution is given from the NDSolve. The code Part[solution1[[1]],1] is mean to take the array of solutions, and then the first one because that would be x.

I also tried to do: x[t] /. solution[[1]] etc etc, that seemed too work just fine for $\alpha$, but then failed for the other things because it keeps saying that the solution[2], solution[[3]] and solution[[4]] do not exist (even though I have those).

Do you see what did I do wrong?

EDIT: Added picture of form of solution1 enter image description here Where v[t],k1[t], k2[t] are given functions of t.

And this is what solution1 looks like: enter image description here

  • $\begingroup$ does ParametricPlot3D[Evaluate[Through[alpha[t]]], {t, 0, 6}] work? $\endgroup$
    – kglr
    Dec 19, 2018 at 22:23
  • $\begingroup$ What are the forms of the solutions, solution1,...? To figure out what's with someone else's code often requires the complete code. $\endgroup$
    – Michael E2
    Dec 20, 2018 at 0:39
  • $\begingroup$ @kglr No it doesn't. $\endgroup$
    – qcc101
    Dec 20, 2018 at 6:36
  • $\begingroup$ @MichaelE2 Edited the question with more info, let me know if you need more. $\endgroup$
    – qcc101
    Dec 20, 2018 at 6:37
  • $\begingroup$ What happens if you get rid of Part and use x[t] /. solution1[[1]], etc.? Alternatively, change the y component to y[t] /. Part[solution2[[1]], 2] or equivalently, y[t] /. solution2[[1, 2]]; similarly for z. $\endgroup$
    – Michael E2
    Dec 20, 2018 at 14:07

1 Answer 1


Always share complete information along with copyable Mathematica syntax.

I suspect that the empty plot is because of extra curls around the entries in alpha[t]. If we go to the documentation of ParametricPlot3D, the syntax is ParametricPlot3D[{fx, fy, fz},{u, a, b}]. I'm guessing that your alpha[t] structure is {{fx},{fy},{fz}}, which is causing the problem.

Anyways, here is an example to follow,

v[t_] = Sin[t];

k1[t_] = Cos[t];

k2[t_] = 5;

a = 0; b = 10;

Eq1 = x'[t] - v[t]*y[t] == 0;

Eq2 = y'[t] - v[t]*k1[t]*z[t] == 0;

Eq3 = z'[t] + v[t]*k1[t]*y[t] + v[t]*k2[t]*w[t] == 0;

Eq4 = w'[t] - v[t]*k2[t]*z[t] == 0;

sol1 = NDSolve[{Eq1, Eq2, Eq3, Eq4, x[0] == 0, y[0] == 1, z[0] == 0, 
    w[0] == 0}, {x, y, z, w}, {t, a, b}];

Eq41 = w'[t] - 1/2*v[t]*k2[t]*z[t] == 0;

sol2 = NDSolve[{Eq1, Eq2, Eq3, Eq41, x[0] == 0, y[0] == 1, z[0] == 0, 
    w[0] == 0}, {x, y, z, w}, {t, a, b}];

Eq21 = 2*y'[t] - v[t]*k1[t]*z[t] == 0;

sol3 = NDSolve[{Eq1, Eq21, Eq3, Eq41, x[0] == 0, y[0] == 1, z[0] == 0,
     w[0] == 0}, {x, y, z, w}, {t, a, b}];

alpha[t_] = {x[t] /. sol1, y[t] /. sol2, z[t] /. sol3};

ParametricPlot3D[Evaluate[Flatten[alpha[t]]], {t, a, b}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.