function-handle Questions

1

In MATLAB R2020b I have the following code: f=@(x) x.^2; y=2; g=@(x) f(x).*y and the output is g = function_handle with value: @(x)f(x).*y But y = 2, so I would expect the output to be @(x)f.*2. ...
Callous asked 24/6, 2021 at 11:59

4

Is it possible to get the derivative of a function_handle as a other function_handle? Like: fun1 = @(x) x^2; % do that ... disp(fun2); @(x) x*2 I know how to find the derivative of a symbol...
Apprise asked 15/1, 2012 at 11:11

2

Solved

vec = randi(10,10,1) vec(vec < 5) = 0 func = @(x) x(x < 5) = 0 % This isn't valid How am I supposed to translate the second line of code into a function handle that I can use in conjunctio...

2

Solved

Using deal we can write anonymous functions that have multiple output arguments, like for example minmax = @(x)deal(min(x),max(x)); [u,v] = minmax([1,2,3,4]); % outputs u = 1, v = 4 But if you w...

1

MATLAB allows overloading various operators for custom classes. One of the unlisted overloadable operators is end, as can be learned from \matlab\lang\end.m: % END(A,K,N) is called for indexing ex...
Westerman asked 31/3, 2017 at 6:42

2

Solved

Say that I have a function foo defined as [a b] = foo(c ). If I consider a function handle f = @(c)foo(c) to be used e.g. in a cellfun call, what I get is an f behaving equivalently to a f...
Frager asked 21/11, 2012 at 9:27

3

Solved

I have a function for cached evaluation. As one of the arguments, it takes a function handle. Under some circumstances, the function handle is unaccessible, and I don't quite understand why. The ex...
Nita asked 16/10, 2013 at 14:46

1

Solved

Is is possible to replace the following code with something which does not use exceptions? The handle x is a provided handle. I want to test it for validity (having actual code to back the handle) ...
Landin asked 10/10, 2013 at 23:10

3

Solved

I started implementing a few m-files in C++ in order to reduce run times. The m-files produce n-dimensional points and evaluate function values at these points. The functions are user-defined and t...
Saleswoman asked 6/9, 2013 at 14:42

1

Solved

Question: In Matlab, how can I check if a function handle is a particular function or function type? Example: Let f1 be a function handle. How do I check if f1 is the in-built Matlab function mean...
Morville asked 12/8, 2013 at 9:30

5

How do I pass a matlab function handle to a Java object and invoke it from within Java (that is, I want Java to tell matlab when it is ready with a calculation). I am trying to use the com.mathwork...
Slapup asked 17/6, 2009 at 8:49

3

Solved

I have some MATLAB programs that use the @ (at sign) as an operator. What does it mean? Does MATLAB 6.5 support this operator?
Polyhydroxy asked 20/1, 2010 at 10:24

1

Solved

If I use the inline function in MATLAB I can create a single function name that could respond differently depending on previous choices: if (someCondition) p = inline('a - b','a','b'); else p = ...
Cirsoid asked 30/11, 2009 at 16:20

1

Working on an assignment involving Genetic Algorithms (loads of headaches, loads of fun). I need to be able to test differing crossover methods and differing mutation methods, to compare their resu...

3

Solved

Can somebody explain to me the meaning of the @ (function handle) operator and why to use it?
Latishalatitude asked 28/4, 2009 at 9:9
1

© 2022 - 2024 — McMap. All rights reserved.