Valueerror: Setting an array element with a Sequence

Asked

Viewed 55 times

1

I can’t fix the error that appears in the code. I have a rotational matrix, trying to calculate rotational forces, that is, radial, axial and tangential force.

Ft2 = np.zeros([janelaanalise,])
Fr2 = np.zeros([janelaanalise,])
Fa2 = np.zeros([janelaanalise,])

i3=0
for i3 in range(janelaanalise):
  Fxyz = np.array([Fxanalise[i3],Fyanalise[i3],Fzanalise[i3]])

  #######
  matrotacao = np.array([(np.sin(a),-np.cos(a),0),(-np.cos(a),-np.sin(a),0),(0,0,1)])
  #######
  Ftra = matrotacao @ Fxyz
  Ft2[i3]   = Ftra[0]
  Fr2[i3]   = Ftra[1]
  Fa2[i3]   = Ftra[2]

Error that appears:

/usr/local/lib/python3.6/dist-Packages/ipykernel_launcher.py:10: Visibledeprecationwarning: Creating an ndarray from Ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with Different lengths or shapes) is deprecated. If you Meant to do this, you must specify 'dtype=Object' when Creating the ndarray # Remove the CWD from sys.path while we load Stuff. --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Typeerror: only size-1 arrays can be converted to Python scalars

The above Exception was the direct cause of the following Exception:

Valueerror Traceback (Most recent call last) in () 11 ########## 12 Ftra = matrotation @ Fxyz ----> 13 Ft2[i3] = Ftra[0] 14 Fr2[i3] = Ftra[1] 15 Fa2[i3] = Ftra[2]

Valueerror: Setting an array element with a Sequence.

  • 1

    What are the variables janelaanalise, Fxanalise, Fyanalise and Fzanalise? Try to make the code as complete as possible, otherwise it is difficult to find the source of the error.

  • Is this the full code? Try to add the full code for better understanding. Please.

  • T = window analysis * dt n = window analysis t = tempojanelavisualizacao data = Fyjanelavisual y = Signal.filtfilt(b, a, data, method='Gust') plt.figure(figsize=(16,5)) plt.lot subplot(1, 2, 1) plt.Plot(tempojanelavisualizacao, data, 'b-', linewidth=1, label='data') plt.Plot(tempojanelavisualizacao, y, 'g-', linewidth=2, label='Filtered data') plt.xlabel('Time [sec]') plt.grid() plt.Legend() plt.subplot(1, 2, 2) plt.Plot(tempojanelavisualizacao, y, 'g-', linewidth=1, label='Filtered data') plt.xlabel('Time [sec]') plt.grid() plt.Legend() plt.subplots_adjust(hspace=0.35) plt.show()

  • I sent the most complete code, but turned into the crazy nigger’s samba

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.