specify Simulink block parameters from Excel cells

2 ビュー (過去 30 日間)
Mat Nub
Mat Nub 2014 年 3 月 4 日
コメント済み: Srinivas 2014 年 3 月 18 日
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
Srinivas
Srinivas 2014 年 3 月 18 日
check the updated script

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSources についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by