MATLAB: Do I have difficulty in using the << operator with the ramp function with mwArray

cMATLAB C/C++ Math Library

Why do I have difficulty in using the << operator with the RAMP function with the mwArray interface?
The following code segment produces an error when compiled to a stand-alone and executed using MBUILD:
1. Create test.cpp from the following C++ code:
#include "matlab.hpp"
void main()
{
mwArray x;
x=ramp(-10,0.1,9);
cout<<x<<endl;
}
2. Compile it using mbuild:
mbuild -setup %select VC++
mbuild -v test.cpp
3. Execute the code:
!test
from the MATLAB prompt.
I should receive the following error message:
abnormal program termination
[
However, if I replace the code in test.cpp with the following:
#include "matlab.hpp"
void main()
{
mwArray x;
x=ramp(-10,0.1,11);
cout<<x<<endl;
}
and run steps 2 and 3 again, I receive a listing of the contents of 'x' rather than the error message.
The problem occurs when the last argument to RAMP is less than 10 (the absolute value of the first variable).

Best Answer

This is a bug in the MATLAB C/C++ Math Library 2.2 (R12.1) that is being investigated by our development staff.
The current work around is to explicitly print the variables out in a FOR loop.
#include "matlab.hpp"
void main()
{
mwArray x;
x=ramp(-10,0.1,9);
for(int i = 0; i<190; i++)
cout<<x(i)<<endl;
}