Reference excel spreadsheet column to retrieve data from corresponding row
11 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
sixwwwwww
2013 年 10 月 12 日
Dear J. Ryan Kersh, can you attach the excel sheet for better insight about the situation?
回答 (2 件)
Walter Roberson
2013 年 10 月 12 日
interp1(temperature_column, enthalpy_column, temperature_to_probe_at)
3 件のコメント
Walter Roberson
2013 年 10 月 12 日
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()
sixwwwwww
2013 年 10 月 12 日
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 件のコメント
sixwwwwww
2013 年 10 月 12 日
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
参考
カテゴリ
Help Center および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!