필터 지우기
필터 지우기

Using imported lookup tables from Excel

조회 수: 2 (최근 30일)
fiona rozario
fiona rozario 2017년 2월 18일
답변: Abhisek Roy 2017년 2월 28일
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
Abhisek Roy 2017년 2월 28일
Hi Fiona,
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.
Abhisek

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by