Simulink/Stateflow Coder Error - failed to create *sfun_debug_macros.h.

Hello,
I'm attempting to implement a simple post-processing function to calculate the mode of a sample. I have a signal buffer immediately prior to a user-defined mode function. I made a test model using a random number generator and then multiplied, rounded, and buffered the signal to achieve the same dimensional input of my real project model. The function performs fine in this test case. The signal in my project model emits from the Index port of a Minimum block.
When I implement the same buffer and user-defined function in my project, I get the following errors:
Coder Error - Stateflow - Failed to create file: C:\...path removed...\*filename*sfun_debug_macros.h.
Model Error - Simulink - Error using ==> sf Error using ==> construct_error at 109 Failed to create file: C:\...path removed...\*filename*sfun_debug_macros.h.
I thought perhaps my student version was limiting me, but I have no issue employing my user-defined function in another model. Any suggestions are much appreciated.

 Risposta accettata

I couldn't figure it out, so I copied all the blocks and pasted them to a new model. Everything works just fine. I'm not sure what setting was changed in my previous model vs. the default model, but that was the difference.

2 Commenti

Great! One thing that possible went wrong is that you may have had a stale "slprj" directory for your old model that was causing issues. This is an intermediate directory that is used by Stateflow charts, MATLAB Functions blocks and other features.
Kaustubha - thank you for this solution.
I has a similar "construct_error at 109" when trying to run my Simulink model which contains a stateflow block. I deleted the "slprj" directory and it now works fine. I suspect the reason it was "stale" may be because I moved the model from a machine running 64-bit matlab to a machine running 32-bit matlab. Presumably some of the files in there needed to be re-generated on the new machine, or something.

Accedi per commentare.

Più risposte (1)

As best I can tell, Simulink Coder and Stateflow Coder are not available for the Student Version.
However, it is not clear to me that you are using Simulink Coder or Stateflow Coder as such.

8 Commenti

I definitely do not have MATLAB Coder, Simulink Coder, or Embedded Coder. I thought this might have been the problem, so I tried the same user-defined function in a small test model. That model runs just fine.
Is that *filename* in the file name literal? backslash asterisk "filename" asterisk sfun_debug_macros.h ?
No, the actual path and filename in the error message are as follows: C:\Users\Mike\Desktop\Research Files\MATLAB Code and Data\Powell EMG Code and Data\Simulink Real Time Pattern Recognition\slprj\_sfprj\Real_Time_Pattern_Recognition_Classifier_Final\_self\sfun\src\Real_Time_Pattern_Recognition_Classifier_Final_sfun_debug_macros.h.
Could you try running "mex -setup", select a selected compiler and rerun the model to see if the error goes away?
I ran mex -setup and selected the same compiler I have been using, and the error is still there. Could it be a dimension issue? I am writing the signal to a workspace variable now. Before adding the buffer and the function, the variable is being saved as 1x1xn. It's just a single value passing through that I want to buffer to 10x1, but perhaps the function mode(x) in my user-defined function is perceiving a 1x1x10. The wire connecting Minimum to Buffer is the only piece that shows no dimensions, and then the signal shows 10x1 going into my user-defined function.
Not a dimension issue - I made the function simply output the input argument, and the function still causes problems.
Do you have a Stateflow chart in your model? Or is your user-defined function using an (Embedded) MATLAB Function block?
I do not have a Stateflow chart. I'm selecting the Matlab Function block from User-Defined Blocks. I have tried copying the function block from my test model where it works as well as generating an identical block in the project model.

Accedi per commentare.

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by