Using imported lookup tables from Excel
3 ビュー (過去 30 日間)
I am new to Matlab and want to use lookup tables. Using the Matlab help on lookup tables I found the following code to import a lookup table form excel -
% Import the data from Excel for a lookup table
data = xlsread('MySpreadsheet','Sheet1');
% Row indices for lookup table
breakpoints1 = data(2:end,1)';
% Column indices for lookup table
breakpoints2 = data(1,2:end);
% Output values for lookup table
table_data = data(2:end,2:end);
I have copied the excel file in the Matlab folder too. Now how do I actually lookup values from the table? What is the command/function? Will I have to necessarily use Simulink?
回答 (1 件)
Abhisek Roy 2017 年 2 月 28 日
Have a look at the following documentation page for interp1. This command allows you to create a 1-D lookup table with your choice of interpolation and extrapolation methods in MATLAB. You can also have a look at 'interp2', 'interp3' and 'interpn' commands for your reference.
In this case, I think that interp2 command will suit your requirement. So, if you see the function signature,'V' will be the data, which you have imported from the EXCEL file and you will need to give coordinates of the sample points as X and Y. Please have a look at the examples given in documentation page for better understanding.