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!