MATLAB Answers

how to input table data in look up table from simulink instantaneously

4 views (last 30 days)
NN
NN on 3 Sep 2021
Commented: NN on 5 Sep 2021
I have a simulink model and i need to input look up table from the simout file in waorkspace during the cource of simulation .Hence how can i input "table data" in look up table from simulink instantaneously.As given in the below MAtlab documentation
This example shows how to use the MATLAB xlsread function in a Simulink model to import data into a lookup table.
  1. Save the Excel® file in a folder on the MATLAB® path.
  2. Open the model containing the lookup table block and in the Modeling tab, select Model Settings.
  3. In the Model Properties dialog box, in the Callbacks tab, click PostLoadFcn callback in the model callbacks list.
  4. Enter the code to import the Excel Spreadsheet data in the text box. Use the MATLAB xlsread function, as shown in this example for a 2-D lookup table.% Import the data from Excel for a lookup table
data = xlsread('MySpreadsheet','Sheet1');
% Row indices for lookup table
breakpoints1 = data(2:end,1)';
% Column indices for lookup table
breakpoints2 = data(1,2:end);
% Output values for lookup table
table_data = data(2:end,2:end);
  1. Click OK.
After you save your changes, the next time you open the model, Simulink® invokes the callback and imports the data.
HEre i have used simout and it produces a 1 x 1 double timeseries data according to the simulation time.How can i use this data as an input to the look up table as mentioned in the below documentation ?
please help

Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 3 Sep 2021
It looks like that you have 1D look up table data imported from MS Excel. Thus, you'd need to use 1D lookup table and just connect the output ports of MS Excel block with the input port of 1D lookup table. See this help doc: https://www.mathworks.com/help/simulink/slref/1dlookuptable.html
It is quite straightforward, once you set up [From MS Excel] data block settings.
  11 Comments
NN
NN on 5 Sep 2021
Thank you very much for th response. now i tried and got it .Data store worksa and it reads and write data . i was trying to analyse why the model shows very less variation in SoC over 24 hour simulation time.In this example MATLAB model, i tried to make changes to third car profile , specifically to input final SoC (which i s given as SE %) instanaeously as input to initial SoC and see the changes .So it should vary SoC asper the model demands each time.It works now with data store, but shows very less SoC %.I dont know why it shows very less % of SoC even during 24 hours of time.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by