converting python script to matlab

조회 수: 11 (최근 30일)
Zahra Sheikhbahaee
Zahra Sheikhbahaee 2020년 11월 2일
댓글: Ameer Hamza 2020년 11월 2일
I am new in Matlab and I am trying to move some part of a python code to my matlab script. I have a bit of problem finding the same functionaltiy of numpy library for matrices in matlab.
I was wondering what would be the equivalent of following lines of code in matlab:
gamma1 = 1. + np.sum(phi[:T-1,:], axis=1)
phi_cum = np.cumsum(phi[:0:-1,:], axis=0)[::-1,:]
gamma2 = alpha + np.sum(phi_cum, axis=1)
lV1 = np.vstack((lV1, 0.))
lV2 = psi(gamma2) - psi(gamma1 + gamma2)
lV2 = np.cumsum(np.vstack((0., lV2)), axis=0)
thanks

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 11월 2일
Check the following function. They are equivalent to the function used in your code
  댓글 수: 2
Zahra Sheikhbahaee
Zahra Sheikhbahaee 2020년 11월 2일
thanks for the answer. Disentangling the indices here is making me confused
np.cumsum(phi[:0:-1,:], axis=0)[::-1,:]
Any suggestion how it will become in matlab?
Ameer Hamza
Ameer Hamza 2020년 11월 2일
This command is equivalent to
y = cumsum(phi(end:-1:2, :))
y = y(end:-1:1, :)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by