This is my code, and I get the following error:
ValueError: NumPy boolean array indexing assignment cannot assign 100 input values to the 90 output values where the mask is true. The error is on the line assigning a value for V.
What am I doing wrong?
from pylab import *
import numpy as np
from math import *
r = np.linspace(0, 10, 100)
V = np.piecewise(r, [r < 1, r > 1 ], [1, (r/2)*(3 - (r**2))])
#Graph of V r / k q vs. r/R for unitless quantities
figure()
plot(r, V)
xlabel('r / R')
ylabel('V r / k q')
title('Behavior of V(r) vs r')
ax = plt.gca()
ax.set_xticks([1])
ax.set_xticklabels(['R'])
plt.tick_params(left = False, right = False , labelleft = False)
grid()
show()