Skip to content
Discussion options

You must be logged in to vote

Hi! The problem is that for historical reasons dots are allowed in variables, so p.k can be a variable with this name. You can actually define p.k = 1. When the function is created, it is compiled for performance and p.k is expected to be a variable later. At this moment, the program does not know if you will pass a variable or vector to p. We cannot change this behavior now because old worksheets may stop working. So, to explicitly specify that p will be a vector, define p=[0] before creating the function. Then p.k will be compiled as the k-th index of vector p.

However, the best and most efficient way is not to use indexing at all, and entirely by vectorized operators functions:

Please…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@javila
Comment options

@javila
Comment options

@Proektsoftbg
Comment options

@Proektsoftbg
Comment options

Answer selected by javila
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants