MATLAB Examples

Display Stepped Range of Python Elements

This example shows how to use an incremental step in indexing.

If you use slicing to access elements of a Python® object, the format in Python is start:stop:step. In MATLAB®, the syntax is of the form start:step:stop.

li = py.list({'a','bc',1,2,'def'});
li(1:2:end)
ans = 

  Python list with no properties.

    ['a', 1.0, 'def']