xlsread to an array by user input with interpolation
Ältere Kommentare anzeigen
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)
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.
Kategorien
Mehr zu Thermal Analysis finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

