Filter löschen
Filter löschen

specify Simulink block parameters from Excel cells

2 Ansichten (letzte 30 Tage)
Mat Nub
Mat Nub am 4 Mär. 2014
Kommentiert: Srinivas am 18 Mär. 2014
I have a Simulink model containing over 300 unit delay blocks. So manually entering sample times is arduous process (copy/paste does not help as sample time differ from block to block). Is there any way for blocks to call sample times from a xls spreadsheet? If not directly from xls could this be done at least from Matlab workspace?
My thinking is to map the blocks in the model as cells in xls and then whatever changes happen in xls model will pickup and put in appropriate block.

Akzeptierte Antwort

Srinivas
Srinivas am 4 Mär. 2014
Yes it can be done from the work space. Declare a parameter for each sample time and define it in your work space.

Weitere Antworten (1)

Mat Nub
Mat Nub am 18 Mär. 2014
Indeed it can be done like this thanks. However once I declare my 300 parameters in blocks how do I make assigning values to parameters automated process while reading from xls itself.
Lets say I declared parameters in Simulink: a b c Then I have a xls table with values 1 2 3 How do I automate the process of reading xls and assigning values to parameters? I get the xls uploaded, but Matlab needs to know what to do with it. How do I get batch execution in command window: a=1 b=2 c=3 ... by reading from xls?
In xlsread Help I found:
"[num,txt,raw,custom] = xlsread(filename,sheet,range,'',functionHandle) reads from the spreadsheet, executes the function associated with functionHandle on the data, and returns the final results. Optionally, returns additional custom output, which is the second output from the function. xlsread does not change the data stored in the spreadsheet. Supported only on Windows systems with Excel software."
I have a feeling I need to use this kind of command, but first I need to map 300 parameters with xls fields. Any ideas?
  3 Kommentare
Mat Nub
Mat Nub am 18 Mär. 2014
hmm, after running this script the workspace result is this:
a=0 b=0 c=0 num=[1,2,3]
in other words the xls cells have ended up as array value of only one variable "num". But I think you are on the right track. The correct result should be: a=1 b=2 c=3
Srinivas
Srinivas am 18 Mär. 2014
check the updated script

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by