Reference excel spreadsheet column to retrieve data from corresponding row

10 visualizzazioni (ultimi 30 giorni)
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 Commenti
sixwwwwww
sixwwwwww il 12 Ott 2013
Dear J. Ryan Kersh, can you attach the excel sheet for better insight about the situation?

Accedi per commentare.

Risposte (2)

Walter Roberson
Walter Roberson il 12 Ott 2013
interp1(temperature_column, enthalpy_column, temperature_to_probe_at)
  3 Commenti
Walter Roberson
Walter Roberson il 12 Ott 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()

Accedi per commentare.


sixwwwwww
sixwwwwww il 12 Ott 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 Commento
sixwwwwww
sixwwwwww il 12 Ott 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

Accedi per commentare.

Categorie

Scopri di più su Data Import from MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by