Importing constants for use in Simulink

4 views (last 30 days)
I have created a model in Simulink that use a number of constants in different types of blocks such as integrator blocks and random value input blocks. I have assigned variable names for these constants so I can vary their value by entering them in the Matlab workspace for example:
Constant = 200;
As the number of constants is around 20 and I will need to vary all of them based on site survey data collected via a spreadsheet, I am looking for a quick way to import the variable names and matching constant values to the workspace from an excel sheet.
Is there a way to import excel data that has the following format in excel:
header row: constant1 constant2 constant3
Row 2: 200 1000 20000
etc. to the workspace so that it will define the constant values as follows:
constant 1 = 200;
constant 2 = 1000;
constant 3 = 20000;

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 10 Oct 2011
There is a way that you can import the data from the Excel file and use the header string as the variable name. You can do it manually once and then let MATLAB generate the code for you. See this post.

More Answers (0)

Categories

Find more on Data Import from MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!