PreviousNext
Help > Programming in Vital Pixels > Using MATLAB
Using MATLAB

In Vital Pixels you can import MATLAB script in M-File and use it in your algorithm. If you have M-File you can use “Build->Import MATLAB Script”. As you see in Fig 7-6 you should select installation folder of MATLAB and then choose your M-File. For using MATAB Script you should check “Import MATLAB Script to Compiler”.

After that you should press “Import” button and waiting for some minutes.

Figure 7‑6. Import MATLAB script to Vital Pixels

This ability is supported only in FullCode . For example in following code you can see a simple code witch use m-file. MWNumericArray is a type that you should use to import value from MATLAB to C#.

// Mohsen.m

function [z] = add(x,y)

z=x+y;

%%

// Full Code

using System.Drawing;

using System.Drawing.Imaging;

using System.Drawing.Drawing2D;

using System;

using System.Collections.Generic;

using System.Text;

using System.Threading.Tasks;

using System.Reflection;

 

namespace VPPlugin

{

 

   public class MyPlugin

   {

     public Image OutPlugin(Image argImage,out string argMessage)

     {

   

          Bitmap bm = new Bitmap(argImage.Width, argImage.Height);

         /// TO DO Program

     

            Class1 v          = new Class1();

            MWNumericArray aa = new MWNumericArray(15);

            MWNumericArray ab = new MWNumericArray(6);

            aa                = 12;

            ab                = 1;

            double a          = Convert.ToDouble(v.mohsen(aa, ab).ToString());

           

            argMessage = "Message"; // TO DO External Message

         return (Image)bm;

     }

 

   }

}