开发者

Difficulties translating Matlab to C

I have some Matlab functions that 开发者_C百科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?


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜