Reference excel spreadsheet column to retrieve data from corresponding row

10 visualizaciones (últimos 30 días)
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 comentarios
sixwwwwww
sixwwwwww el 12 de Oct. de 2013
Dear J. Ryan Kersh, can you attach the excel sheet for better insight about the situation?
J. Ryan Kersh
J. Ryan Kersh el 12 de Oct. de 2013
I have attached the excel spreadsheet. Thanks again.

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 12 de Oct. de 2013
interp1(temperature_column, enthalpy_column, temperature_to_probe_at)
  3 comentarios
Walter Roberson
Walter Roberson el 12 de Oct. de 2013
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()

Iniciar sesión para comentar.


sixwwwwww
sixwwwwww el 12 de Oct. de 2013
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 comentario
sixwwwwww
sixwwwwww el 12 de Oct. de 2013
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

Iniciar sesión para comentar.

Categorías

Más información sobre Data Import from MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by