How to import data from excel to be used on a 3-D lookup table in Simulink?
4 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(1 个)
Mohith Kulkarni
2020-9-23
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
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:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Nonlinearity 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!