xlsread to an array by user input with interpolation
1 view (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Guillaume
on 10 Nov 2015
Edited: Guillaume
on 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.
See Also
Categories
Find more on Thermal Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!