1

I call a *.m function from C# :

  matlab.Feval("shoulderDetector", 3, out result, pic, colorPicR, colorPicG, colorPicB);

When I compile, this line opens the Command Window for matlab and sends the 4 variables(All variables are from live camera) to shoulderDetector.m that calls another 3 matlab funcitions... There is an error there "matrix exceeds it indices..." Is there a way knowing what's going on with data in matlab without printing everything in the CMD matlab window ?

If not, what is the best way detecting a bug ?

7
  • Can you debug a function inside Matlab? Commented Aug 8, 2015 at 16:28
  • yes, but variables I send to matlab are from a streaming camera that i can get only from C# or C++ ! Commented Aug 8, 2015 at 16:30
  • I understand that but can't you somehow import the data into matlab, or write a test function that sets up the data and then calls the function that has the problem? Commented Aug 8, 2015 at 16:31
  • I recorded a sample and sent 500 frames to matlab, it worked ok. I get the problem while live streaming, by the way it's Intel Realsense camera, that I have no idea how to get data live to matlab and debug it there ! Commented Aug 8, 2015 at 16:47
  • 1
    No, it's not a joke. You need to log what happens, add logging code everywhere. If you can't debug, that's all you can do. If you can't reproduce the problem reliably (and by that in this context I really mean feed it some input and watch it crash) then you need to "be there" when the problem happens. If you can't debug, excessive logging is the best you can do. Commented Aug 8, 2015 at 17:30

2 Answers 2

1

Unless you want to debug in software designed for debugging Matlab code, there is no way to do it. I would put debugging output to the console in the Matlab code where you think you can catch the issue, (e.g. near the problematic matrix) and output the indexes and any other information that might be helpful.

Sign up to request clarification or add additional context in comments.

Comments

1

Unfortunately there is no good solution debugging solution for Matlab when you come across different programming languages.

I reccomend to replace your function temporarily with this one:

function varargout=genericSaveArgs(varargin)
varargout=cell(nargout,1);
callArgs=varargin;
save('callArgs.mat','callArgs');
end

which saves the parameters, then call your original function using:

cc=load('callArgs.mat')
[a,b,c]=shoulderDetector(cc.callArgs{:})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.