Search code examples
c#time-seriesmatlab-deployment

Integrating Mat Lab Functions with C#


I have this Time Series function with Mat Lab:

function y = time(a, b, c, d, e, f, g, h, i, j, k, l)
x = [a b c d e f g h i j k l];
ts1 = timeseries(x,1:12);
ts1.Name = 'Monthly Count';
ts1.TimeInfo.Units = 'months';
ts1.TimeInfo.Format = 'mmm dd, yy';
ts1.Time=ts1.Time-ts1.Time(1);
plot(ts1);

I have deployed it as a C# library. Now how can I call the function 'time' and pass the parameters?

Thanks for your help


Solution

  • The C# library generated will be called something based on your MATLAB compiler project settings - let's say it's MyMatLabLib.dll. Once you have included MyMatLabLib.dll to your .NET project, you should be able to use it like this:

    using MyMatLabLib;
    public class MatLabWrapper
    {
        public MatLabWrapper()
        {
            var ml = new MyMatLab();
            ml.time( /* pass in MWArrays as parameters */ )
        }
    }