Equivalent python for a matlab line?

Hi all,
May I know how could I represent the following line to python:
X = y(z(i,1:12),1);

2 commentaires

Chetan Bhavsar
Chetan Bhavsar le 15 Oct 2021
can you provide value of y and z plz
Mark Sc
Mark Sc le 15 Oct 2021
@Chetan BhavsarThank you for your answer,
values are y=[0 1 2;3 4 5]
z=[1 2 3 4;4 5 6 7]

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 15 Oct 2021
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]

Catégories

Question posée :

le 14 Oct 2021

Commenté :

le 15 Oct 2021

Community Treasure Hunt

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

Start Hunting!

Translated by