Equivalent python for a matlab line?

조회 수: 2 (최근 30일)
Mark Sc
Mark Sc 2021년 10월 14일
댓글: Mark Sc 2021년 10월 15일
Hi all,
May I know how could I represent the following line to python:
X = y(z(i,1:12),1);
  댓글 수: 2
C B
C B 2021년 10월 15일
can you provide value of y and z plz
Mark Sc
Mark Sc 2021년 10월 15일
@Chetan BhavsarThank you for your answer,
values are y=[0 1 2;3 4 5]
z=[1 2 3 4;4 5 6 7]

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

답변 (1개)

Walter Roberson
Walter Roberson 2021년 10월 15일
X = Y[z[i, 0:11],0]
would be my guess.
However, this relies upon the values in z having been changed to index 0 based instead of index 1 based. If the computation of z values was left the same between the two language, with the result that the minimum possible z value was 1 and you want that to indicate the first element in Y, then you would have to subtract 1:
X = Y[z[i, 0:11]-1,0]

카테고리

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