Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to pass an object of LinearModel Class as output to a .Net Interface ?

조회 수: 1 (최근 30일)
Rahul Sivagaminathan
Rahul Sivagaminathan 2018년 8월 22일
마감: MATLAB Answer Bot 2021년 8월 20일
I have a function that i am compiling using Matlab Compiler (to create a DLL for .Net Assembly). The function uses the input and develops a Linear model using stepwise regression. Here is the code
function [Rsq,Mdl] = DevelopModels(Input,Output)
Mdl = LinearModel.stepwise(Input,Output,'linear','verbose',0);
Rsq = Mdl.Rsquared.Ordinary ;
end
I then compile this function using Matlab compiler into a DLL for .Net Assembly. Here is the code in C#
CollectData cd = new CollectData();
int[,] designSamples = new int[,]
{
{ 0, 10 ,5 ,150},
{ 0 , 205,25 ,125 },
{ 0 ,400 ,5 , 100 },
{ 50 ,10 ,15 , 100 },
{ 50 ,400 ,25 , 150 },
{ 100 ,10 ,25 , 150 },
{ 100 ,205 ,15 , 150 },
{ 100 ,400 ,5 , 125 },
{ 100 ,400 ,25 , 100 },
{ 100 ,10 ,5 , 100 },
};
int[] exampleRankings = new int[]
{
2 ,
3 ,
6 ,
4 ,
7 ,
6 ,
5 ,
8 ,
8 ,
5
};
MWNumericArray designSamplesMW = new MWNumericArray(designSamples);
MWNumericArray rankingsMW = new MWNumericArray(exampleRankings);
MWArray[] models = cd.DevelopModels(2, designSamplesMW, rankingsMW);
On the .Net side when i try to use this DLL, i get proper values in Rsq but Mdl is returned as NULL. What am i doing wrong ? Can i not return mdl as output to .NET ?

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by