3

I am using matlab NE builder to compile a dll file which I call from C#. The matlab code is confirmed to work in matlab, but when called from c# the following error occurs:

An unhandled exception of type 'System.Exception' occurred in MWArray.dll

Additional information:

... MWMCR::EvaluateFunction error ... Subscript indices must either be real positive integers or logicals. Error in => KalmanFilter.m at line 108.

The line in question is the following:

plot(data(:, 1), data(:, 2));

I have confirmed that when the line is reached, the variable data has size n by 4, with n > 50, why the statement is supposed to make sense.

Anyone got any experience on this? Thanks in advance

Fredrik Bagge
  • 1,351
  • 8
  • 20
  • Can you please post more code – noobob Jan 23 '13 at 08:03
  • Just before the line that causes problems I added the line 'save debugdata data' After inspecting the variable data prom the saved file, I can conclude that everything is in order, and running the line in matlab with the data loaded from the file works fine. – Fredrik Bagge Jan 23 '13 at 08:13
  • As far as I know, this issue arise when you name variables as you function names or as MatLAB functions (reserved names). Make sure this is not happening. – noobob Jan 23 '13 at 08:16
  • @noobob , that is actually exactly what had happened. If I saved and examined the whole workspace, there were a variable present called plot. How this found it's way there is somewhat of a mystery since the code still runs well in matlab. Anyhow, thank you for your input! – Fredrik Bagge Jan 23 '13 at 08:31
  • Also see [this question](http://stackoverflow.com/questions/20054047/subscript-indices-must-either-be-real-positive-integers-or-logicals-generic-sol) for [the generic solution to this problem](http://stackoverflow.com/a/20054048/983722). – Dennis Jaheruddin Nov 27 '13 at 15:46

1 Answers1

4

As far as I know, this issue arise when you name variables as you function names or as MatLAB functions (reserved names). Make sure this is not happening.

noobob
  • 532
  • 4
  • 12
  • that is actually exactly what had happened. If I saved and examined the whole workspace, there were a variable present called plot. How this found it's way there is somewhat of a mystery since the code still runs well in matlab. Anyhow, thank you for your input! – Fredrik Bagge Jan 23 '13 at 08:45