How to import data from excel to be used on a 3-D lookup table in Simulink?

4 visualizaciones (últimos 30 días)
I am trying to use a 3-D table on SIMULINK just like shown on this link https://www.mathworks.com/help/simulink/slref/2dlookuptable.html
The idea is that the imputs would be a row value, a column value, and a page value. To my understanding, MATLAB has the capability of interpolating in all dimensions if values don't match.
When I try to import my excel file I can only import a table but it won't import the other pages.
Any ideas of how to deal with it?
Here there are some illustrations
Excel File:
MATLAB 3-D Table desctiption:
When I import it to MATLAB it is only a 2-D table:
Any ideas/recomendations are much appreciated!

Respuestas (1)

Mohith Kulkarni
Mohith Kulkarni el 23 de Sept. de 2020
Hi,
You can create a spreadsheetDatastore object to read data from multiple sheets into MATLAB. Refer to the example code below, make sure to change the values according to your data.
ds = spreadsheetDatastore('fileName.xlsx'); %specify file
ds.Sheets = [1 2]; %specify sheet numbers
ds.Range = 'B1:D4'; %specify range
ds.ReadSize = 'sheet'; %specify to read one sheet everytime read is called
data = zeros(3,3,2); %i have 3x3 data in 2 sheets for my dummy data
for i = 1:length(ds.Sheets)
data(:,:,i) = table2array(read(ds));
end
For more help related to reading data Refer to Read Collection or Sequence of Spreadsheet Files.
After reading the data you can go ahead and import lookup table data from MATLAB by specifying the variable name("data" in this case) in the "Table data:" field of n-D Lookup table block parameters. For more information on this refer to the below link:

Categorías

Más información sobre Nonlinearity en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by