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
1 answer

How can I fix the link between the multiplier and eqn(x)?

I am right now stuck on a problem in matlab. What I have done is that I have an equation that is passed on into another function which works by the bisection-method. But I have a multiplier that I am trying to implement which somehow leads to the…
user5128359
0
votes
2 answers

Linear transformation function handle

Assume I have the legendre polynomials in cell Array P as function handles. Now I use the linear transformation x = 2/3*t-1. Now I want to get a cell array Q which has the transformation function handle. So P = [1, @(x) x, 1/2*(3*x^2-1),...] to Q =…
0
votes
1 answer

ezplot in MATLAB, how to plot using a function handle?

I've tried this: linefunca = @(xa,ya) aa*xa + ba*ya + ca; figure(1) imshow(Pica); hold on; ezplot(linefunca,[1,1072,1,712]); But I'm returned with this error: In an assignment A(I) = B, the number of elements in B and I must be the same. Error…
Robbie Capps
  • 417
  • 1
  • 5
  • 16
0
votes
1 answer

significance of ~ symbol in matlab function

If I have a function a that accepts 2 parameters (double) in Matlab as follows function [x,y] = a(z) What does the symbol "~" do when the function is called with this handle as follows [x,~,y] = a[10] Thanks
Raja Sattiraju
  • 1,262
  • 1
  • 20
  • 42
0
votes
1 answer

Creating anonymous function handle dynamically in MATLAB using numeric matrices as sources

I'm kinda lost in a problem where I need to (dynamically) create an anonymous function handle from huge matrices and 192 variables. I'll try to give you an (easier) example of what I have to do and what I have in mind to achieve it (but without a…
frrrt
  • 89
  • 8
0
votes
1 answer

How do I create function handle from cfit, multiply with other function handle and integrate the term?

I try to get an integral of two function handles in Matlab. The first function handle would be a weibull probability density function and the second function handle is based on a cfit I created with linear interpolation of single points. x =…
Simon
  • 3
  • 3
0
votes
2 answers

Create flexible function handle

I am using numerical integration in MATLAB, with one varibale to integrate over but the function also contains a variable number of terms depending on the dimension of my data. Right now this looks like the following for the 2-dimensional case: for…
0
votes
1 answer

Plotting a function handle of two variables

I have the following code: f1_p1 = @(xq1) interp1(x_j1,p1,xq1); f2_p1 = @(xq2) interp1(x_j2,p1,xq2); new_p1x1 = @(xq1,xq2) f1_p1(xq1).*f2_p1(xq2); To plot f1_p1 and f2_p2 is easy, I do: fplot(f1_p1, [30,70]) My question How can I plot the second…
Sergio Haram
  • 437
  • 4
  • 17
0
votes
1 answer

Multiplying two function handle and applying ode45 to the result

I have the following functions in discrete form (which means that they are arrays): p1_1 of dim(200x1) p1_2 of dim(200x1) p1_3 of dim(200x1) p2_1 of dim(200x1) p2_2 of dim(200x1) p2_3 of dim(200x1) The functions p1_1, p1_2, p1_3 have being…
Sergio Haram
  • 437
  • 4
  • 17
0
votes
1 answer

MATLAB - Integral 2 - First input argument must be a function handle

I need to use the integral2() function with syntax: q = integral2(fun, xmin , xmax, ymin , ymax). I've tried the commands: Alphai(: , 1) = {@(x,y) Alpha(1,1)+Alpha(2,1)*x+Alpha(3,1)*y}; Alphai(: , 2) = {@(x,y)…
user3121718
  • 33
  • 1
  • 8
0
votes
1 answer

How to build an array by function handle

I am trying to produce something like this in MATLAB with function handle f=@(x,y)(x(1)*x(2)+y); c=[2 3 4;5 9 2]; h=[5 1 2]; f(c,h) The answer should be: 15 11 12 But when I write this code below, it just builds a number not an…
0
votes
1 answer

Graphing the difference of two handle-functions in matlab

I have two handle-functions, their graphs are very close to each other, I can see this by plotting both functions. f = @(x1); ff = @(x2); fplot(f, [0 1],'r') hold on fplot(ff, [0 1],'b') hold on I would like to have another graph where I take the…
Sergio Haram
  • 437
  • 4
  • 17
0
votes
1 answer

Trying to solve ODE system in MATLAB yields the following error: "Undefined function 'exist' for input arguments of type 'cell'"

I'm having a bit of difficulties when I try to solve an ODE system of two equations in MATLAB. The code I am using is the following: x0=-1; %Initial condition for variable x y0=-10; %Initial condition for variable…
0
votes
0 answers

MATLAB nested handle returning multiple outputs

I have a function handle that returns 3 values. @f(x,y) = basis_handle(x,y); [z, dx, dy] = f(0.1,0.1) %returns 3 vectors what I'd like to do now is create a function handle that performs a dot product of each of those 3 vectors with another…
Lukas Bystricky
  • 1,222
  • 6
  • 16
  • 34
0
votes
2 answers

Matlab integral function & function handles in a loop

'Outliers.m' is called from a higher level .m file. The variables are all defined in the higher level file, and set as globals for access by Outliers.m. The purpose of the code is to identify outliers using Chauvenets Criterion, and for this, I have…
1 2 3
10
11