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

1 vue (au cours des 30 derniers jours)
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.

Réponse acceptée

Guillaume
Guillaume le 29 Juil 2019
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 commentaires
Guillaume
Guillaume le 29 Juil 2019
Modifié(e) : Guillaume le 29 Juil 2019
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.
rammah nagi
rammah nagi le 29 Juil 2019
Modifié(e) : rammah nagi le 29 Juil 2019
Thank you that did the trick!!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by