programming with matlab and .NET C#

조회 수: 3 (최근 30일)
Hui
Hui 2014년 4월 30일
댓글: Walter Roberson 2016년 11월 18일
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?

채택된 답변

Daniel Pereira
Daniel Pereira 2014년 4월 30일
편집: Daniel Pereira 2014년 4월 30일
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
Limin Wang
Limin Wang 2016년 11월 18일
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?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 .NET Client Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by