specify Simulink block parameters from Excel cells

2 次查看(过去 30 天)
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.

采纳的回答

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

更多回答(1 个)

Mat Nub
Mat Nub 2014-3-18
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 个评论
Mat Nub
Mat Nub 2014-3-18
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by