specify Simulink block parameters from Excel cells

3 vues (au cours des 30 derniers jours)
Mat Nub
Mat Nub le 4 Mar 2014
Commenté : Srinivas le 18 Mar 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.

Réponse acceptée

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

Plus de réponses (1)

Mat Nub
Mat Nub le 18 Mar 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 commentaires
Mat Nub
Mat Nub le 18 Mar 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 le 18 Mar 2014
check the updated script

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by