Caching result of pre-computed function in Matlab

前端 未结 3 1542
不思量自难忘°
不思量自难忘° 2021-01-07 06:53

I have two arrays, x and y. x is the input of the function and y is the function values. For example, x = [ 1 2 3 4

3条回答
  •  情歌与酒
    2021-01-07 07:18

    I think that you just want:

    y(z);  
    

    This will return the z'th elements of the y vector. You may want

    y(x(z));
    

    Which will return the same result in your example, since x is just the value 1 through 10.

    With both of these z can contain only positive integers, and in the second case x must also contain only positive integers.

提交回复
热议问题