does the matlab R2017a deploy neural network for c#(.net Assemly)

조회 수: 1 (최근 30일)
wahed fazeli
wahed fazeli 2017년 12월 28일
댓글: Kojiro Saito 2018년 1월 10일
i use matlab R2017a but when i want to deploy my code to c#(.net assembly) it has a lot of error my code is very simple but i dont know why the matlab dont compile it in c#(.net assembly) these are snapshots of error in compiling neural network.
does the c# visual studio run my code with this errors because the matlab created files specially dll file(does this dll file work in the visual studio?) this is my simple code of neural network
function neuralnetwork(x,t)
net= fitnet(10);
disp('Training fitnet');
train(net,x,t);
end
does this version just have this problem?

채택된 답변

Kojiro Saito
Kojiro Saito 2017년 12월 30일
편집: Kojiro Saito 2018년 1월 10일
From R2017a, a feature was added to MATLAB Compiler to show warnings if unsupported functions are used in compiled scripts. But there's an issue in R2017a that many warnings of unsupported Fixed-Point Designer (toolbox/fixedpoint/fixedpoint) will be shown in PackagingLog.html even though those functions of Fixed Point Designer are not used in compiled MATLAB scripts. I think this issue was solved in R2017b.
So, you can ignore the warnings of "toolbox/fixedpoint/fixedpoint" in PackagingLog.html because you don't use Fixed-Point Designer functions in your neuralnetwork.m. I confirmed your script is able to compile and run as a standalone, so I think there's no issue for .NET assembly.
UPDATED:
I also tested with MATLAB R2017a and .NET (Console application) and it worked fine.
I have compiled as .NET assembly from your neuralnetwork.m, specifying appname "neuralnetwork" as the attached screenshot.
Here is a sample #C code.
Program.cs
using System;
using MathWorks.MATLAB.NET.Arrays;
using neuralnetwork;
namespace neuralnetwork
{
class neuralnetworkClass
{
static void Main(string[] args)
{
Class1 obj = null;
MWNumericArray arrayX = null;
MWNumericArray arrayT = null;
MWArray[] result = null;
int numOfOutput = 0;
try
{
// Instantiate your component class.
obj = new Class1();
// Invoke your component.
arrayX = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
arrayT = new double[]{0, 0.84, 0.91, 0.14, -0.77, -0.96, -0.28, 0.66, 0.99};
result = obj.neuralnetwork(numOfOutput, arrayX, arrayT);
// print the output.
Console.WriteLine("Neural Network Done");
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
}
}
You need to do the following.
1. Add two dll files (compiled neuralnetwork.dll and $MATLAB\toolbox\dotnetbuilder\bin\win64\v4.0\MWArray.dll) to the Reference of your .NET solution file in Visual Studio.
2. Specify Platform target to 64bit in Visual Studio.
Hope this help.

추가 답변 (1개)

wahed fazeli
wahed fazeli 2018년 1월 9일
i test the compile file but it doesnt work .in your opinion do i use the matlab r2017b?
  댓글 수: 1
Kojiro Saito
Kojiro Saito 2018년 1월 10일
I tested with compiled .NET dll (in MATLAB R2017a) and worked. I have updated the above answer with sample C# program.

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

카테고리

Help CenterFile Exchange에서 MATLAB Compiler SDK에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by