How to import data from excel to be used on a 3-D lookup table in Simulink?
2 ビュー (過去 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!