How to import data from excel to be used on a 3-D lookup table in Simulink?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/358915/image.png)
MATLAB 3-D Table desctiption:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/358918/image.png)
When I import it to MATLAB it is only a 2-D table:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/358921/image.png)
Any ideas/recomendations are much appreciated!
0 Kommentare
Antworten (1)
Mohith Kulkarni
am 23 Sep. 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
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 Kommentare
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!