matlabequalitycontrol-theorytransfer-function

Index of non-number element in Matlab


I have defined an array with transfer functions inside it. How can I find the position of a certain transfer function inside that array?

s = tf('s') % defining a transfer function
array = [s, s^2, s^3];
>> find(array==s)
undefined function 'eq' for input arguments of type 'tf'.

Solution

  • Compare each element of the array with s using isequal:

    arrayfun(@(x)isequal(x,s),array)