From: Matthew Lenda on
Hey all,

I'm running an autopilot simulation in Simulink, and it requires the use of some very fancy nonlinear equations of motion and vector field stuff. Rather than turning these equations into block diagram form, I already had the code written up for them and decided to use them in an embedded function block.

Well, running the simulation directly in Simulink or using the sim.m function in an m-file both return the following error:

"Unable to locate 'mexopts.bat', and therefore cannot determine which compiler to use for simulation builds.
Use 'mex -setup' to select a supported compiler."

When I run "mex -setup", it says there are no compilers to choose from.

There are lots of embedded functions that I wish to use in this simulation so there isn't an obvious workaround. I've got lots of other Simulink sims (state space stuff, some other randoms) that do not use embedded MATLAB code blocks, and they run just fine.

Need-to-knows...
-I am running 64-bit MATLAB
-My OS is 64-bit Windows 7
-I know little to nothing about compilers.
-I have pretty much every blockset you can imagine for Simulink (thank you, university licenses!)

Let me know if you need any other information.
From: Matthew Lenda on
"Matthew Lenda" <lendam(a)gmail.com> wrote in message <hig6vo$g7t$1(a)fred.mathworks.com>...
> Hey all,
>
> I'm running an autopilot simulation in Simulink, and it requires the use of some very fancy nonlinear equations of motion and vector field stuff. Rather than turning these equations into block diagram form, I already had the code written up for them and decided to use them in an embedded function block.
>
> Well, running the simulation directly in Simulink or using the sim.m function in an m-file both return the following error:
>
> "Unable to locate 'mexopts.bat', and therefore cannot determine which compiler to use for simulation builds.
> Use 'mex -setup' to select a supported compiler."
>
> When I run "mex -setup", it says there are no compilers to choose from.
>
> There are lots of embedded functions that I wish to use in this simulation so there isn't an obvious workaround. I've got lots of other Simulink sims (state space stuff, some other randoms) that do not use embedded MATLAB code blocks, and they run just fine.
>
> Need-to-knows...
> -I am running 64-bit MATLAB
> -My OS is 64-bit Windows 7
> -I know little to nothing about compilers.
> -I have pretty much every blockset you can imagine for Simulink (thank you, university licenses!)
>
> Let me know if you need any other information.


With the help of a friend, I got the correct compiler in place. Running the sim from an m-file using "sim.m", I get the following output in the Command Window.

Embedded MATLAB parsing for model "cupic_simulator"...Done
Embedded MATLAB code generation for model "cupic_simulator"....Done
Embedded MATLAB compilation for model "cupic_simulator"... 1 file(s) copied.
Done
??? Error using ==> cupic_simulator_script at 56
Error reported by S-function 'sf_sfun' in 'cupic_simulator/Nonlinear Equations of Motion (Embedded Function)/ SFunction ':
Error calling generated SFunction, cupic_simulator_sfun.

So it looks like I got a bit further, but now it just won't tell me what's wrong with the function.

I tried a very simple simulation/model with a very simple embedded function -- same error.