specify Simulink block parameters from Excel cells

조회 수: 3 (최근 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 CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by