Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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}]
share|improve this answer
    
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... –  rubenvb May 26 '11 at 15:54
    
@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. –  Mr.Wizard May 27 '11 at 1:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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