MATLAB Answers

0

use C# lib in MatLab

Asked by Roland Thamm on 13 Sep 2019
Latest activity Answered by Kojiro Saito on 14 Sep 2019
How can I use a C# Library with MatLab

  0 Comments

Sign in to comment.

Tags

Products


Release

R2019b

1 Answer

Answer by Kojiro Saito on 14 Sep 2019

You can call your C# library by loading dll using NET.AddAssembly and call its function.
Here is a simple example in this document.
In this example, NetDocCell.dll is used and it is compiled from NetDocCell.cs described in C# NetDocCell code in this document.
Here is a snippet to call C# dll.
dllPath = fullfile(pwd, 'NetDocCell.dll');
% Load C# dll
asm = NET.addAssembly(dllPath);
% Creat a C# class
graph = NetDocCell.MyGraph;
% Create cell array containing all data
mlData = cell(graph.getNewData);
% Plot the data and label the graph
figure('Name',char(mlData{1}))
plot(double(mlData{2}(2)))
xlabel(char(mlData{2}(1)))

  0 Comments

Sign in to comment.