coder and error passing handles to extrinsic functions
Show older comments
Hi all,
I have written some code in matlab using a primary function that calls fsolve and a subfunction for passing extra arguments to the function being solved.
function out1 = RxCase2(pin1,pin2,pin3,pT,pVpore,options)%#codegen
global in2 in3 T Vpore
in2=pin2;
in3=pin3;
T=pT;
Vpore=pVpore;
varlogic = logical([1 1 0 1 0 0]);
pin1(varlogic) = feval('fsolve',@NLeqset2,pin1(varlogic),options);
out1 = TotalSol2(pin1);
...
function [out1,out2] = NLeqset2(in1)
global in2 in3 T Vpore
...
function out1 = TotalSol2(in1)
global in2 T Vpore
...
However I get the error 'Function handles cannot be passed to extrinsic functions' when compiling. This function does work as a native matlab function.
I also tried coder.extrinsic('fsolve'), but it seems that I can't pass the function handle to the fsolve() routine. I am running into problems because it seems most ways to pass extra parameters use function handles, fsolve needs to be passed @NLeqset2, and the coder is not compatible with fsolve() (only fzero which works by calling it without feval; i.e something like fzero(@NLeqset,x0)).
Does anyone have any suggestions on how to pass the arguments to the subfunction and pass the subfunction to fsolve() in a way that can be compiled?
1 Comment
Santosh Gnanasekar
on 27 May 2019
Iam as well trying to construct the similar function
But didnt work. Could you please help me out ?
Accepted Answer
More Answers (0)
Categories
Find more on Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!