Home/Support/Support Forum/The input arrays have incompatible shapes.
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

The input arrays have incompatible shapes.

0 votes
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal as sig
# Parameters defining the system
c = 4 # Damping constant
k = 2 # Stiffness of the spring
m = 20 # Mass
F = 5 # Force
Ft = np.ones(610)*F
# Simulation Parameters
t=np.linspace(1,100,1000)
# System matrices
A = np.array(0, 1,0,0], [-k/m, -c/m,0,c/m],[0,0,0,1],[0,c/m,k/m,c/m)
B =np.array(0,0],[1/m,0],[0,0],[0,1/m)
C =np.array(1, 0,0,0],[0,0,1,0)
D=np.array(0],[0)
sys = sig.StateSpace(A, B, C, D)
print(sys)
t, y, x = sig.lsim(sys, Ft, t)
plt.plot(t, x)
#plt.plot(t, y)
plt.title('Simulation of Mass-Spring-Damper System')
plt.xlabel('t')
plt.ylabel('x(t)')
plt.grid()
plt.show()

this is the error : ValueError: The input arrays have incompatible shapes.
asked Feb 25 in 3rd Party Python and API development in other Languages by mandm New to the Community (0 points)

Please log in or register to answer this question.

...