'Matlab Syntax and Python Syntax
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?
Solution 1:[1]
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!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
