MATLAB Answers

How can I use Function handle with arrays?

I'm trying to use function handle with arrays. My objective is to create a function which picks a particular element of one dimensional row matrix. It need to output the particular element when I pass matrix and index as arguments. I know there are other ways to do this, but I'm very much interested to see whether this task can be done by function handle or not
syms I t
G = matlabFunction(I(t))
A = [1 2 3];


Sign in to comment.

1 Answer

Answer by Adam
on 14 May 2019
Edited by Adam
on 14 May 2019
 Accepted Answer

Not really sure how the code you posted, with syms and matlabFunction is connected to what you are asking, but this function should do what you ask:
f = @(x,idx) x(idx)

  1 Comment

Sign in to comment.