I am trying to update a variable (Nped) inside a while loop in Spyder.
This variable defines the lenght of the arrays (Qsie_ocup_vetor and fe_ocup_vetor) in the loop.
On the first interaction (densidade=0.1), it works well, but on the second, it does not work and the following mensage appears: “TypeError: only size-1 arrays can be converted to Python scalars”.
It follows a part of my code:
Area=3
densidade=0.1
while (densidade<0.9):
# Date of the Gauss distribution
M_mean=718.2/9.81
M_std=143.6/9.81
fp_Mean=2.0
fp_std=0.175
# Initializing the variable
Nped=0
Nped=int((Area*densidade))
# Initializing the vector
Qsie_ocup_vetor=np.zeros(Nped)
fe_ocup_vetor=np.zeros(Nped)
# Computing...
for i in range (Nped):
Qsie_ocup_vetor[i]= 'here apears an equation'
fe_ocup_vetor[i]= 'here apears an equation'
print(densidade,Qsie_ocup_vetor[i],fe_ocup_vetor[i])
# End of the loop: updating the variable "densidade"
densidade=densidade+0.1