List indexing

fschneider's Avatar

fschneider

09 Sep, 2021 09:23 AM

Hi Chris,

How do I extract parts of a list? I realise that I can index single values from a list variable and use a while loop for operations, however, this seems computationally expensive. Is there a quick way to flexibly extract several entries from a list (similar to Matlab/Python syntax)?

var[0:n]
var[n:m]
var[n:end]

Also, is there a built-in feature to sum or average lists?

Cheers
Felix

  1. Support Staff 1 Posted by Christopher Sta... on 09 Sep, 2021 09:01 PM

    Christopher Stawarz's Avatar

    Hi Felix,

    How do I extract parts of a list? I realise that I can index single values from a list variable and use a while loop for operations, however, this seems computationally expensive. Is there a quick way to flexibly extract several entries from a list (similar to Matlab/Python syntax)?

    Unfortunately, no -- MWorks doesn't support this. As a workaround, you could perform complex list manipulation in Python (via run_python_file, run_python_string, or the py_eval function).

    Also, is there a built-in feature to sum or average lists?

    No, but you could use Python for this, too.

    Cheers,
    Chris

  2. Christopher Stawarz closed this discussion on 01 Oct, 2021 02:10 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac