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?
Walter Roberson
Walter Roberson 2016 年 11 月 18 日

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File 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