Spencer Preston
Spencer Preston

Reputation: 11

Simulink - Use .Mat as extern input variable to auto-coded c function

I have a Simulink model that I was able to auto-code. I set some of the inputs (vx,vy,vz, x,y,z) that I needed to change as extern, and this works fine so far. Now I need access to the .Mat data file (think GPS almanac data) that will change based on test week. Instead of having to re-autocode with the new .Mat in my workspace it would be great if I could set that as an extern and feed it data from my .cpp wrapper like the rest of the variables. Any tips would be awesome!

Upvotes: 1

Views: 590

Answers (1)

Phil Goddard
Phil Goddard

Reputation: 10762

The -p optional input to the Rapid Simulation Target is designed for this purpose, although the format of the .mat file must be of a specific type.

An example can be found here: Using RSIM target over range of parameter values.

It shows creating the mat file in MATLAB, but it could be created in C or C++ using the appropriate mat file API: MAT-File API Library and Include Files

Upvotes: 2

Related Questions