1

I have a Matlab code that I have to convert into python. There is this one operation that I am currently struggling with. I have a Matlab array "edof" which has the dimensions 262144 x 24. I have a second array "dofVector" which has the dimensions 823875 x 1. The operation performed is:

edof = dofVector(edof);

which updates my variable and I get the resulting dimensions of the variable "edof" to be the same as before i.e 262144 x 24 but the values are changed.

I am trying to convert this line of code in numpy but have been unable do so.

edof = dofVector[edof]

I get the following error. the error message

Can someone please help me here?

I am not including the description of the arrays here as this is highly technical and specific to my field.

Thank you!

1 Answer 1

2

Numpy indices are zero-based. MATLAB indices are one-based. So if edof is identical between MATLAB and Python up to that step, you'll want to do

edof = dofVector[edof - 1]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.