Reference excel spreadsheet column to retrieve data from corresponding row

Hi, I am trying to find a way to pull corresponding values from an excel spreadsheet. I have 3 columns of data, in this order: Temperature, Enthalpy, Entropy.
Temperature ranges from 10-220 degrees with the corresponding enthalpy and entropy values in each row.
Is there a way to give MATLAB a value for temperature, and have it return the corresponding value for ONLY one of my two other columns? (i.e. - can I put in 20 for temperature and have it return the correct value for entropy?)
Is there a good help section/topic to explore to learn more about this coding/process?
Thank you in advance for your advice.

댓글 수: 2

Dear J. Ryan Kersh, can you attach the excel sheet for better insight about the situation?
I have attached the excel spreadsheet. Thanks again.

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

답변 (2개)

interp1(temperature_column, enthalpy_column, temperature_to_probe_at)

댓글 수: 3

J. Ryan Kersh
J. Ryan Kersh 2013년 10월 12일
편집: J. Ryan Kersh 2013년 10월 12일
Thank you for the help. I would use this after the the "xlsread" command, correct?
Also, will the "interpl" command actually interpolate values if the input is between data points on the excel spreadsheet?
Yes you are right
You can change the manner in which the interpolation is done by changing the options to interp1(). For example one of the options is "nearest"
If you want "last location that is at or before the probe location" then usually using histc() is better than using interp1()

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

Dear J. Ryan Kersh, Walter Roberson's answer is correct. If you have confusion you can use the following code directly:
Temperature = xlsread(filename, 'A:A');
Enthalpy = xlsread(filename, 'B:B');
Entropy = xlsread(filename, 'C:C');
Search_at_temperature = input('Input temperature to find enthalpy and entropy at: ');
% Use to find Enthalpy for given temperature
Output_Enthalpy = interp1(Temperature, Enthalpy, Search_at_temperature);
disp(strcat('Enthalpy is: ', num2str(Output_Enthalpy)))
%Use to find Enthalpy for given temperature
Output_Entropy = interp1(Temperature, Entropy, Search_at_temperature); % Use to find Enthalpy for given temperature
disp(strcat('Entropy is: ', num2str(Output_Entropy)))

댓글 수: 1

I will like to add one comment here. In your excel sheet you have two temperature values same at 123.54 so please remove one of these two rows to use above code because otherwise function "interp1" doesn't work

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

카테고리

도움말 센터File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

질문:

2013년 10월 12일

댓글:

2013년 10월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by