Questions tagged [function-handle]

In Matlab, a function handle is a mechanism provided to allow for indirect calling of a function. Serves like a "pointer to function"

A function handle is a value that provides a means of calling a function indirectly.

159 questions
0
votes
2 answers

Matlab, function handle auto use parameter

Hi I have a question about how to achieve the following behaviour in Matlab. A.x=pi A.sin=@()sin(A.x) A.sin() % Returns 1.2246e-16, essentially 0 so all good so far. % Now for the problem A.x = pi/2 A.sin() % Returns 1.2246e-16, meaning the new…
wookie1
  • 511
  • 6
  • 18
0
votes
0 answers

Function handler

I'm using two distinct functions on matlab: function1 and function2 (each written in a different script). In the script of function1, I have something like: function result = function1(y,z) result = function2(@(x)do_this(x,y,z),…
bigTree
  • 2,103
  • 6
  • 29
  • 45
0
votes
3 answers

Matlab: Save matrix of function handles to a text file

For example my data is: data = [1000] @(x)x.^2 @sin [0.5] [2000] @(x)1./x @cos [0.6] I want to save data to a text file or another. (data is a cell matrix). How can I achieve this?
newzad
  • 706
  • 1
  • 14
  • 29
0
votes
2 answers

Cannot pass function handle as an argument of a function

I'm new to Matlab and I'm trying to write custom function in matlab that would take function handle as one of its arguments. I'm getting this error all the time: Error using subsindex Function 'subsindex' is not defined for values of class…
Rasto
  • 17,204
  • 47
  • 154
  • 245
0
votes
2 answers

MATLAB: calling GUI/GUIDE functions from outside

When I try to invoke a subfunction in a GUI/GUIDE file (using a function handle which has been exposed as a global variable), a new axes is always created even if I set the axes to a specific axes in the GUIDE figure. Does anyone know why this is…
jakob
-1
votes
1 answer

Nested call to integral fails

Try this piece of code, which works fine. a=1;b=2; % A two-variate function f2= @(x,y) x+y; derivedF2=@(x) integral(@(y) f2(x,y), a,b); % Test the evaluation of the derived function handle derivedF2(0); % Test the integration of the derived…
user2008151314
  • 680
  • 6
  • 10
-1
votes
2 answers

Matlab: Passing all arguments to a function handle

I run a lot of function on a series of files. so it's logical to make a function that runs my functions on files instead repeating the procedure in every file. The problem is number of arguments for every function is different! So the psudo-code…
anishtain4
  • 2,342
  • 2
  • 17
  • 21
-3
votes
1 answer

Matlab : Using function handle in eval does not substitute?

Is it not possible to do such an evaluation? I create a function using eval (class verifies a function handle is created) Then I use eval to use this function handle. But it does not evaluate, resulting with the function itself. Tried many different…
halukb
  • 1
-3
votes
2 answers

Calculate function in matlab

is there any way to calculate a function in matlab using toolbox? for example I have this function: f(x,y)=x^2+y^2, I want to set x=2 and y=2 and function take back 8. How can I do it? Thanks
starrr
  • 1,013
  • 1
  • 17
  • 48
1 2 3
10
11