Hello,
I'm trying to use fsolve in a shared c++ library created by Matlab (7.10.0.499 32 bits) for Visual Studio 2008 SP1 (with the deploy tool).
I can use lsqlin without any problem, but it seems to be more painful when using function handles ...
I wrote a .m file with the following function :
function y = matlab_solve(arg1, arg2, arg3)
fhandle = getHandleFunc(arg1, arg2, arg3);
function fhandle = getHandleFunc(a1, a2, a3)
function F = func(x)
F = ... (using a1, a2 and a3);
end
fhandle = @func;
end
x0 = ...;
y = fsolve(fhandle, x0);
end
I wrote these nested functions as I need to create a function F depending on the inputs arg1, arg2 etc.
However, when using the function matlab_solve in my C++ program, I got the error :
??? Undefined function of method 'lsqfcnchk' fo input arguments of type 'function_handle'.
So two questions come to my mind :
- can I use a nested function for fsolve ?
- if I have some inputs for the general function matlab_solve, can I use them inside the definition of the nested functions ?
Looking forward to hear some comments,
Thanks,
Benoit
|
|
0
|
|
|
|
Reply
|
Benoit
|
10/12/2010 6:43:04 PM |
|
Instead of creating function handle, just concatenate the arguments, pass these arguments as string. The concatenated argument can then go as a inline function input to fsolve.
"Benoit Brot" wrote in message <i92a7o$b6v$1@fred.mathworks.com>...
> Hello,
>
> I'm trying to use fsolve in a shared c++ library created by Matlab (7.10.0.499 32 bits) for Visual Studio 2008 SP1 (with the deploy tool).
>
> I can use lsqlin without any problem, but it seems to be more painful when using function handles ...
>
> I wrote a .m file with the following function :
>
> function y = matlab_solve(arg1, arg2, arg3)
> fhandle = getHandleFunc(arg1, arg2, arg3);
>
> function fhandle = getHandleFunc(a1, a2, a3)
> function F = func(x)
> F = ... (using a1, a2 and a3);
> end
>
> fhandle = @func;
> end
>
> x0 = ...;
> y = fsolve(fhandle, x0);
> end
>
> I wrote these nested functions as I need to create a function F depending on the inputs arg1, arg2 etc.
>
> However, when using the function matlab_solve in my C++ program, I got the error :
> ??? Undefined function of method 'lsqfcnchk' fo input arguments of type 'function_handle'.
>
> So two questions come to my mind :
> - can I use a nested function for fsolve ?
> - if I have some inputs for the general function matlab_solve, can I use them inside the definition of the nested functions ?
>
> Looking forward to hear some comments,
> Thanks,
> Benoit
|
|
0
|
|
|
|
Reply
|
ddmandaliya (1)
|
5/3/2012 6:38:07 PM
|
|
|
1 Replies
312 Views
(page loaded in 0.117 seconds)
Similiar Articles: BASIC problem calling LIB$ RTL - comp.os.vmsProblems arise when I call the dll function from 100 ... how to monitor network status using C/C++ library ... ... Using thread-specific data in shared ... window handle ... Errors when integrating MatLab code into C# program - comp.soft ...... is 64 bit, but I am still encountering this problem. ... Error building C shared lib on Linux - comp.soft-sys ... and i run into the error ... path loading function handle C ... the maximum memory size allowed in malloc - comp.lang.cI'm using the school's library computer. The malloc() function expects an argument of type ... and they can) then there's no problem ... Maximum shared memory segment size ... loading a DLL from memory - comp.os.ms-windows.programmer.win32 ...... the code in your link few days ago, but the problem ... it for reading and make it auto-delete once the handle ... Error building C shared lib on Linux - comp.soft-sys.matlab ... writing robust software? - comp.lang.c++.moderatedBut there are problems, where even GC doesn't help, e ... as a possible bug type (that is: > > directly using C ... C/C++ library for point cloud & mesh manipulation ? - comp ... Invisible window, like console app - comp.os.ms-windows.programmer ...I suspect the problem you're running ... console-type app and sends using NULL as the handle ... You'd be better off using another IPC mechanism COM, or a shared pipe ... efficiency in awk - comp.lang.awkThe last one is the biggest problem. I use an option-processing library ... Lesser problems: - Doesn't handle nulls in the input ... to do it is to add -f /usr/share ... A problem with performance - comp.graphics.api.openglI assume the data is shared ... different, i.e. as a function of the zoom. > I think my big performance problem is ... never have a problem with performance, using Matlab ... Sockets in gfortran? - comp.lang.fortran... someone seen or developed Fortran code to handle sockets via C? ... C:\eq>cd lib C:\eq\lib>dir Volume in drive C ... unused parameter sig client2.c: In function tcp ... Examples of C++ in Safety Critical Systems - comp.lang.c++ ...They wanted >>> > to revert to pure C. These are just scratch of problems ... allocation, the Ada version is function ... implement C++ logic on top of our C library ... using fsolve in a shared c++ lib, problem of fu... - Newsreader ...Thread Subject: using fsolve in a shared c++ lib, problem of function handle Linux Tutorial - Static, Shared Dynamic and Loadable Linux Libraries... avoids the Microsoft "DLL hell" problem ... dlsym(lib_handle, "ctest1"); Returns address to the function which has been loaded with the shared library.. 7/30/2012 8:07:27 PM
|