Problem with plotting and printing inside a loop

As such, print(m) works as long as before the loop you set each time:

θ = 0.01
ϵ = 1.0

but you probably want to use print("$m ") or println(m) to easily read it.

As said by @apo383 for the plot you need something more and different (and, being only 1 point each time, you should use scatter!). So:

plot()
while θ < 2
    m0 = 0.1
    while ϵ > 0.001
        m = μ*tanh(J/(μ*θ)*m0 + h)
        print("$m ")
        ϵ = abs(m-m0)
        m0 = m
    end
    display(scatter!([θ],[m]))
    θ += dθ
end
3 Likes