Thread Subject:
Generating C code for Simulink model with .mat

Subject: Generating C code for Simulink model with .mat

From: Adriaan

Date: 30 May, 2012 16:33:09

Message: 1 of 2

Hi,

I have a Simulink model that loads its parameters from a .MAT file by means of an init-function (Model Properties - Model Callbacks - Init function):
load('modeldata.mat');


Now I would like to generate a C code of this model by means of Real Time Workshop, but I am always getting an error "Undefined variable modeldata" .

Does anybody know how to generate a C code for a Simulink model that needs to load a .mat file before running?


regards,
Adrian

Subject: Generating C code for Simulink model with .mat

From: Phil Goddard

Date: 31 May, 2012 04:30:26

Message: 2 of 2


Model (and block) callback routines are executed by the MATLAB engine and are not part of the simulation loop (which is essentially what gets converted to C code with Simulink Coder/RTW).

But you can use the RSIM target to execute a model while getting its parameters from a .mat file.
See
>> doc rsimgetrtp
and the demo
>> edit rtwdemo_rsim_param_survey_script.m

Phil.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
simulink Phil Goddard 31 May, 2012 00:34:31
simulink ccode Adriaan 30 May, 2012 12:34:17
rssFeed for this Thread

Contact us