xlsread to an array by user input with interpolation

Problem getting the user inputs for Pressure (P1 & P2) to extract an array. The left column of the spreadsheet imported will be the Pressure, column 2 will be Temperature, 3 enthalpy, 4 entropy.
What I am trying to do is take P1 and P2 from the user input and pull the respective row of P1 and P2. If they do not match the exact numbers in the spreadsheet that I have (there is 10-40 numbers between each pressure value) then the code should execute a linear interpolation routine to find the exact enthalpy and entropy.

Antworten (1)

Guillaume
Guillaume am 10 Nov. 2015
Bearbeitet: Guillaume am 10 Nov. 2015
Use interp1 to get your temperature, enthalpy and entropy for both P1 and P2 all at once. The simplest way is to keep all these values together in a matrix:
sat_interpolated = interp1(sat_numeric(:, 1), sat_numeric(:, 2:end), [P1, P2]);
%column 1, 2, 3 of sat_interpolated are T, H, S respectively. row 1 is P1, row 2 is P2
As an aside:
P1 = input(SomePrompt)
while P1 < 0 || P1 > 1600
P1 = input(ExactSamePromptThatYouHadToRetype)
end
could be written more simply as
P1 = -Inf
while P1 < 0 || P1 > 1600
P1 = input(PromptThatYouOnlyHaveToWriteOnce)
end
Same for P2.

2 Kommentare

Thank you for your assistance... I should elaborate a bit more. P1 & P2 are two pressures in two different states. P1 comes from a Tab 1 (Saturated_R134a) and P2 comes from Tab 2 (Superheated_R134a) of my spreadsheet (Thermodynamics_R134a_tables.xls).
I suppose it would need to be something like the statement above but inside of an "if" statement?
If the user defined P1 doesnt match one of the numbers in column 1 then calculate a regression in the middle of the two closest figures.
<<
>>

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Thermal Analysis finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 10 Nov. 2015

Kommentiert:

am 10 Nov. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by