필터 지우기
필터 지우기

how to interpolate a value from an excel file depending on an input and then assign the result to a variable.

조회 수: 2 (최근 30일)
Hi,
I am trying to model a refrigeration compressor, i am trying to use input values from an excel file to then find the corresponding temperature values in the steam tables. once the corresponding temperature is found, the values of pressure (column B), enthalpy( column I) and entropy (column L) need to found. I need help with one of these columns and I should be able to handle the rest.
% Refrigeration Calculations
Temperatureout = 'Tcout.xlsx';
Tempinlet = xlsread(Temperatureout);
% Tin = Tempinlet(;,1)
%% State 1
R134aTemp = 'R134a_TempSat.xlsx';
%Pin =
As you can see the temperature into the compressor can be found in the Tcout excel file. I am trying to find the corresponding pressure which is in the R134a_Tempsat excel file. Since the exact temperature may not be there linear interpolation may be used.

채택된 답변

Guillaume
Guillaume 2019년 7월 29일
In modern matlab, I'd recommend you use readtable instead of xlsread, particularly if your excel file has column headers since these will be read and used to create variable names by readtable. In this case, it's simply:
TempSatLookup = readtable('R134a_TempSat.xlsx');
%assuming that the file has two columns named Temperature and SatPressure:
queryTemp = 100; %some value. Not sure where this come from. Can be a scalar or a matrix
MatchingPressure = interp1(TempSatLookup.Temperature, TempSatLookup.SatPressure, queryTemp)
If you use xlsread, or in modern matlab readmatrix, and temperature is 1st and saturation pressure 2nd column:
TempSatLookup = xlsread('R134a_TempSat.xlsx');
queryTemp = 100; %some value. Not sure where this come from. Can be a scalar or a ma
MatchingPressure= interp1(TempSatLookup(:, 1), TempSatLookup(:, 2), querytemp)
  댓글 수: 3
Guillaume
Guillaume 2019년 7월 29일
편집: Guillaume 2019년 7월 29일
queryTemp can come from wherever you want. If your query temperatures are all the values you've read in Tempinlet, then replace queryTemp by TempInlet in the above in order to look up the saturation pressure of all these temperatures at once.
If that's not what you're asking then I'm lost and providing example spreadsheets may help understanding your question better.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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