Matlab Coder / Compiler and Classes

Hello,
I am trying to deploy some matlab code that I have written to both speed up and hopefully call from a C# program. I am experiencing a number of issues with unsupported functions that can probably be resolved but at a more general level is there 'good' support for converting an application that has been developed primarily in matlab classes... the support page 'Code Generation Features Not Compatible with Classes' has caused concern.
What I really need to know is - is it worth the effort of trying to fix the unsupported functions? Will I find myself defeated at the class / architecture level and therefore be better placed to start rewriting the application in C++/C#?
Any advice / previous experiences greatly appreciated.
TIA, David

 採用された回答

Titus Edelhofer
Titus Edelhofer 2015 年 1 月 14 日

0 投票

Hi David,
leaving the speedup aspect aside another option would be to use MATLAB Compiler and MATLAB Builder NE http://www.mathworks.com/products/netbuilder/. There you don't have the restrictions as with MATLAB Coder.
Titus

6 件のコメント

David
David 2015 年 1 月 14 日
Titus,
If I am honest I have always been slightly confused with the differences between Matlab Coder, Compiler, and Builder NE. I will get busy reading and see if we have a license for them...
Is it your understanding that they would support classes directly rather that having to wrap them in functions? Similar in structure to the noddy example below.
i.e
classdef classA < handle
properties
classB % a class as a property that does something useful
end
methods
function classA(classB)
obj.classB = classB;
end
function result = doSomething(classC)
result = obj.classB.doSomething(classC);
end
end
end
Titus Edelhofer
Titus Edelhofer 2015 年 1 月 14 日
Hi David,
the combination Compiler/Builder NE bundles your code into something that can be called from .NET. It supports most of MATLAB (there are some restrictions, e.g. interactive apps from toolboxes).
Supporting classes directly: you don't have to wrap classes into other classes. What you can't do though is passing objects across the .NET/MATLAB boundary, so you can only call functions from .NET. Within those functions you can use classes as you like.
Titus
Sean de Wolski
Sean de Wolski 2015 年 1 月 14 日
Compiler and Builder NE run MATLAB Code against the MCR so the full language is supported as the MCR is essentially a headless MATLAB.
I usually wrap my classes in a function (literally, just calls the main class) and use the function as the main file for compiled applications but the algorithm everything else remains in classes.
David
David 2015 年 1 月 14 日
Going slightly off topic - can similar speed gains be achieved through Compiler and Builder NE as with coder - I need speed!. We ran some metrics initially using coder and were able to achieve acceptable speed (reasonably large monte carlo task) - 10x speed increase as mex 80x faster as dll when compiled using coder vs matlab
Sean de Wolski
Sean de Wolski 2015 年 1 月 14 日
Compiler will be about the same as MATLAB since it's running against the same MATLAB engine - no conversion to C is happening.
Have you considered using parallel computing and/or a GPU for the monte-carlo simulations?
Titus Edelhofer
Titus Edelhofer 2015 年 1 月 15 日
Although you can often speed up MATLAB code using MATLAB Coder, if you have a speed up that large it could be that you are using MATLAB language not in an optimal fashion. I guess you already tried to profile your code using profiler?
Titus

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

その他の回答 (0 件)

製品

Community Treasure Hunt

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

Start Hunting!

Translated by