MATLAB talk:Inline Function

From PrattWiki
Jump to navigation Jump to search
  • Can arguments put in to the inline function be functions themselves or do they have to be defined numbers?Yd31 11:48, 25 January 2012 (EST)
    • The items in the first argument can include functions. The second argument and beyond need to be variable names. But you can certainly have something like
      c = inline('sqrt(a.^2+b.^2)', 'a', 'b')
      
      which uses the function sqrt as a part of the inline. Also, when calling the function, you can have functions that return values - for example:
      MyVal = c(cos(pi/6), sin([1 2 3]*pi/6))
      
      which would return the three values of the function for the single value of the first argument matched against the three values of the second.DukeEgr93 13:35, 25 January 2012 (EST)