What is the best way to iterate over an array based on an index in Matlab?

I saw this topic talking about map: Map function in MATLAB?

As a result, I wondered if there are similar ways to do this with indexes in mind. For example, if I want to do something like (x_i) ^ i.

Many thanks!

+3
source share
1 answer

Example:

>> x = randi(10, [1 5])
x =
     9     7     4    10     1

>> x.^(1:numel(x))
ans =
    9      49    64   10000  1
+4
source

Source: https://habr.com/ru/post/1733786/


All Articles