I have a Matlab function and I could run it from the Matlab without any error, but after deploying it to .Net Assembly and use it in C# I get this below error:
System.Exception
  HResult=0x80131500
  Message=
... MWMCR::EvaluateFunction error ... 
The logical indices contain a true value outside of the array bounds.
Error in => startx.m at line 42.
... Matlab M-code Stack Trace ...
    at
file startx.m, name startx, line 42.
  Source=MWArray
  StackTrace:
   at MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction(String functionName, Int32 numArgsOut, Int32 numArgsIn, MWArray[] argsIn)
   at MathWorks.MATLAB.NET.Utility.MWMCR.EvaluateFunction(String functionName, MWArray[] argsIn)
   at matlabTest.Form1.Button4_Click(Object sender, EventArgs e) in C:\Users\AhadOZU\source\repos\matlabTest\Form1.cs:line 71
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at matlabTest.Program.Main() in C:\Users\AhadOZU\source\repos\matlabTest\Program.cs:line 19
 Ahad aghapour
 Ahad aghapourUser contributions licensed under CC BY-SA 3.0