1
$\begingroup$

Why won't this output the VectorPlot? It outputs number (that even seems correct for the application), but I can't get a picture out of them :(

BbuitenBolR[r_, \[Theta]_, R_] := Cos[\[Theta]] (1 - R (3 + R^2 - 3 R Coth[R])/r^3) /. R -> 1
BbuitenBolT[r_, \[Theta]_, R_] := -Sin[\[Theta]] (1 + R (3 + R^2 - 3 R Coth[R])/r^3) /. R -> 1
BbinnenBolR[r_, \[Theta]_, R_] := Cos[\[Theta]] (3 R)/Sinh[R] (r Cosh[r] - Sinh[r])/r^3 /. R -> 1
BbinnenBolT[r_, \[Theta]_, R_] := -Sin[\[Theta]] (3 R)/( 2 Sinh[R]) ((1 + r^2) Sinh[r] - r Cosh[r])/r^3 /. R -> 1
Br[r_, \[Theta]_, R_] := Piecewise[{{BbinnenBolR[r, \[Theta], R], r <= R}, {BbuitenBolR[r, \[Theta], R], r > R}}];
Bt[r_, \[Theta]_, R_] := Piecewise[{{BbinnenBolT[r, \[Theta], R], r <= R}, {BbuitenBolT[r, \[Theta], R], r > R}}];
Bx[x_, z_, R_] := x/ArcCos[z/Sqrt[x^2 + z^2]] Br[ArcCos[z/Sqrt[x^2 + z^2]], ArcCos[z/Sqrt[x^2 + z^2]], R] + z/ArcCos[z/Sqrt[x^2 + z^2]] Bt[ArcCos[z/Sqrt[x^2 + z^2]],  ArcCos[z/Sqrt[x^2 + z^2]], R]
Bz[x_, z_, R_] := z/ArcCos[z/Sqrt[x^2 + z^2]] Br[ArcCos[z/Sqrt[x^2 + z^2]], ArcCos[z/Sqrt[x^2 + z^2]], R] - x/ArcCos[z/Sqrt[x^2 + z^2]] Bt[ArcCos[z/Sqrt[x^2 + z^2]], ArcCos[z/Sqrt[x^2 + z^2]], R]
Manipulate[N[Bx[1, 1, R]], {R, 1, 10}]
Bz[1, 1, 1] // N

Manipulate[ VectorPlot[{N[Bx[x, z, R]], N[Bz[x, z, R]]}, {x, -10, 10}, {z, -10, 10}], {R, 1, 10}]

I'm sorry for the messy code, but Mathematica copy-pastes that way. I checked out the Piecewise examples and the VectorPlot examples, but no luck on combining the two :( Is there an alternative way to do this?

Thanks!

$\endgroup$

1 Answer 1

1
$\begingroup$

Your use of /. R -> 1 seems strange to me. What do you mean to accomplish with that?

Nevertheless, adding Hold gives output of some kind:

Manipulate[VectorPlot[Hold@{N[Bx[x, z, R]], N[Bz[x, z, R]]}, {x, -10, 10}, {z, -10, 10}], {R, 1, 10}]
$\endgroup$
2
  • $\begingroup$ Yeah, that should be removed. I changed the function to use HeavisideTheta instead of Piecewise, and now it works as it should. Don't really know where I went wrong... $\endgroup$
    – rubenvb
    May 26, 2011 at 15:54
  • $\begingroup$ @rubenvb, would you consider posting your new code, if not in this question, then perhaps to codereview.stackexchange.com ? Also, I don't think this answer deserves the check mark; it has no explanation, and was a quick fix (if it even gives the right output) I stumbled upon before I had to leave. I can take another look at this in about six hours. $\endgroup$
    – Mr.Wizard
    May 27, 2011 at 1:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .