Excel Interpolation in MATLAB function

5 ビュー (過去 30 日間)
Marwan Ibrahim
Marwan Ibrahim 2017 年 9 月 18 日
回答済み: Image Analyst 2017 年 9 月 18 日
Hi, I am writing a code that is supposed to read values from excel table, the table consists of 2 columns temperature and viscosity. The user should enter the the temperature and the code returns the corresponding viscosity. and if the temperature is not in the table, the code should interpolate to get the corresponding viscosity. So far I managed to do the first part(that if the temperature is in the table the code returns the viscosity).But I am having difficulty in the interpolation part. For example if the user enters temperature=27 the result will be 0.000855,
but if the user enters temperature=30 the code will not work.
Hope I made myself clear.
function b = watermiu(a)
data = xlsread('water temp miu.xlsx');
index = data(:,1) == a;
b = data(index,2);

回答 (1 件)

Image Analyst
Image Analyst 2017 年 9 月 18 日
You might try splines. See attached demo and adapt as needed.

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by