Akhneyzar
Akhneyzar

Reputation: 1004

Difficulties translating Matlab to C

I have some Matlab functions that I have to translate in C but I do not understand the syntax or the behaviour to create.

I have this call and the following implementation:

{
...
[vSolution,sReturnVal] = Func1(10, @(X) Func2(X, hour_of_the_day));
...
}

function [SolutionVector,ReturnValue] = Func1(IterationsTermination, FuncToUse)

function [ReturnValue] = Func2(TestedSolution, shour_of_day)

I thought that the '@(x)' was there to define an anonymous function possessing an X parameter (a simple pointer to function), but is here used with a named function with parameters, and the X value define within the parameter list.

How can I understand it and translate it in C?

Upvotes: 1

Views: 133

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272487

It is defining an anonymous function. But that anonymous function happens to call Func2. The anonymous function is equivalent to:

function Y = myFunc(X)
Y = Func2(X, hour_of_the_day);

Upvotes: 1

Related Questions