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