How can I use specific input data from excel into simulink?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi , the question may seem stupid or too easy! but please read my question carefully. I have created my simulink model, and I used virtual input data using random number, sine wave etc. but now, I want to use real input data. I have the number like [x,y] from my excel file and I would like to put into my simulation but it doesn't work.
To simplify the question, for example, assume you have;
z=x+y
x= 1,3,5,8
y= 2,2,5,7
and the answer should be z= (1+2=3), 5, 10, 15
x and y are your real data, and your function/system is "z", how can I model this very simple function in SIMULINK.
if you reply this question, all other stuffs will be solved!
thank you very much in advance
0 Commenti
Risposte (1)
Ganesh Gaonkar
il 28 Ott 2014
Hi Mehrad,
One of the way using which you can bring the excel data into the Simulink is by using Signal builder block. you can add the following sample code in the 'PostLoadFcn' callback in the Model properties:
[num,txt] = xlsread('test_data');
block = signalbuilder('test/Signal Builder', 'append', num(:,1), num(:,2), '');
Where ‘test_data’ is the name of the Excel file and ‘test’ is the name of the Simulink model file. When you open the model with the signal builder block, follow the below steps:
1) Navigate to File>Model Properties.A dialog box opens up.
2) Go to CallBacks tab and click on PostLoadFcn. Paste the above mentioned code. Placing the code in the PostLoadFcn callback means that the code is executed whenever the model is loaded and therefore you will find two signal groups already present in the signal builder block.
3) To confirm that the above code works correctly, delete the second signal group, save the model, close and then reopen the model. The two signal groups should again be present in the signal builder block.
The above code appends a signal group with one signal into the signal builder block. It can be modified to add more than one signals. Hope this helps!
0 Commenti
Vedere anche
Categorie
Scopri di più su Sources in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!