0
votes

I have the following code in Matlab,

n = 5;
ainit = zeros(1,n); 
    for i=1:ndof
            ainit(i) = 0; 
    end
    
binit = zeros(1,ndof); 
disp(binit)
x0 = [ainit,binit];

tf = 10; step = .001; tspan = 0:step:tf
funky=@(t,x) A*x + BF; %beam(t,x,K,M,wns,psi2,Load);
[t2,q2] = ode23(funky,tspan, x0, []); 

where both 'A' and 'BF' are n x n square matrices.

I am trying to convert this code into python. So far I have as follows,

y0 = np.zeros((4*n))
Time_Step = np.arange(0, 10, 0.001)
func = lambda x, t: (A*x+BF)
q = scipy.integrate.solve_ivp(func, Time_Step, y0)

This gives me an error that states 'could not broadcast input array from shape (20,20) into shape (20,)' which is because 'A' and 'BF' are n x n.

If anyone could help properly translate the code that would be much appreciated thank you!