UndefVarError: θ not defined

You need a global θ declaration in this loop, since the loop is in global scope. (It wouldn’t show up if you were writing your loop in a function.)

See Scope of Variables · The Julia Language

This is the infamous global-scope rule (Global variable scope rules lead to unintuitive behavior at the REPL/notebook · Issue #28789 · JuliaLang/julia · GitHub); the error message should be clearer in Julia 1.5.

3 Likes