.MEX file Segmentation Violation

2 views (last 30 days)
Erwin Manuel
Erwin Manuel on 2 Jul 2011
Hi All,
I have a program I want to edit: adm1_ODE.c (I 'think' this program is already standard and widespread), I wanted to add inputs so I simply changed parameter in line: ssSetNumContStates(S, 43); /* number of continuous states*/. All I did is change 42 to 43. However when I run the program, this results to Matlab System Error and the details state segmentation violation. Any clue/suggestion? Thanks in advance!

Answers (1)

Jan
Jan on 3 Jul 2011
Beside setting the number of state, you have to define the new state also. You can use either a debugger for the C-code or set some mexPrintf commands in the code until you find the line, which causes the crash.
  1 Comment
Kaustubha Govind
Kaustubha Govind on 5 Jul 2011
I second Jan's suggestion to debug your S-function. Here are some instructions: http://www.mathworks.com/help/toolbox/simulink/sfg/bq2rjeu-1.html
There could be something you're doing wrong in accessing the states.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!