I am trying to rewrite matlab code in Python. Everything was good so far, but this last equation is not coming together no matter what I do. I'm guessing it is just my poor understanding of matlab syntax. So here is the matlab equation ( Un(100, 1), a(100,1), X_basis(100,100)
):
uN=uN+(a(i)*X_basis(:,i));
Every numpy array has been "translated" and the values match, except uN
. That is what I tried to do in Python:
for i in range(1, N+1):
uN[i] = (a[i] * X_basis[:][i])
and I tried the uN = uN + ...
version, and still, the results don't match (at all). Any idea what I am doing wrong?
I got it
for i in range(1, N+1):
uNtemp[i] = np.transpose(X_basis)[:][i] * float(a[i])
for i in range(1, M+1):
uN[i] = np.sum(np.transpose(uNtemp)[i])
It turns out Matlab basically does this piece of code. Thank you all for your comments!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.