programming with matlab and .NET C#
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hui
el 30 de Abr. de 2014
Comentada: Walter Roberson
el 18 de Nov. de 2016
Hello ,all!
I want to pack the nlinfit method as a Class(.NET assembly) so I can use in my C# application. But there is a problem:
There are four parameters in nlinfit method:( X,Y,MODELFUN,BETA0 ) . Among them X Y and BETAO all are matrix(Class Array can be transform to Class MWArray in C#),but parameter MODELFUN is a funtion in matlab. What does function in matlab means in .NET?
0 comentarios
Respuesta aceptada
Daniel Pereira
el 30 de Abr. de 2014
Editada: Daniel Pereira
el 30 de Abr. de 2014
I would suggest what I think is the easiest way:
If MODELFUN is a matlab function handle, use inside your "matlab method" the command str2func , in order to transform a string into a function handle
function out = mynlinfit(X,Y,MODELFUN,BETA0)
MODELFUN2 = str2func(MODELFUN); % MODELFUN is a string. e.g: '@(x) cos(x)'
% MODELFUN2 is a function handle.
out = nlinfit(X,Y,MODELFUN2,BETA0);
Now, MODELFUN2 is a function handle (which can be used in the original nlintfit), while your method's input MODELFUN is a string, which you don't need to cast in C#, as .NET strings are directly interpreted by matlab.
Hope it helps.
3 comentarios
Limin Wang
el 18 de Nov. de 2016
In my case, the MODELFUN is not a matlab function but a function in C#. How could I transfer this function from C# to Matlab? Now I want to pack the gaoptimset method:( FINESSfCN,nvars,...)in the matlab toolbox as a Class(.NET assembly) so I can use in my C# program, but FINESSfCN is a function in my C# program. What should I do to transfer the function in the C# to the gaoptimset method?
Walter Roberson
el 18 de Nov. de 2016
Answered in your Question http://www.mathworks.com/matlabcentral/answers/312932-how-could-i-transfer-the-function-from-c-to-matlab
Más respuestas (0)
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!