フィルターのクリア

Matching two columns from an imported table to find the corresponding value in the 5th column.

1 回表示 (過去 30 日間)
I have a 401 x 12 table that was imported from excel into matlab. I want a function that returns a value from the 5th column when I give two values from the first two columns.
  2 件のコメント
Sebastian Daneli
Sebastian Daneli 2022 年 2 月 2 日
You need to specify your question. Can you give an example?
Samuel Ofosu-Yeboah
Samuel Ofosu-Yeboah 2022 年 2 月 2 日
Alright. Sure.
The table has headings as Temperature, Pressure, Density, Internal energy, and Enthalpy as shown below. I want a function that takes a particular temperature and pressure to return the corresponding Enthalpy. Lets say, in the function I put 360 as temperature and 175.5 as density and it returns 2608 as enthalpy.
Hope this is much clearer. Thanks

サインインしてコメントする。

採用された回答

Enrico Gambini
Enrico Gambini 2022 年 2 月 2 日
編集済み: Enrico Gambini 2022 年 2 月 2 日
One method to extract what you want could be
temp=input("Insert temperature: \n"); %here you insert the parameters in the command window
%Otherwise you can do manually from the code
temp=360; %you can change it
Then you can create your function code file
function enthalpy=find_enthalpy(temp)
idx=find((Table.Temperature(:)==temp); %i called "Table" your table from excel
enthalpy=Table.Enthalpy(idx);
fprintf("The enthalpy is :",enthalpy); %not necessary
end
From your script, or directly from command window you can call the function
enthalpy=find_enthalpy(temp)
Let me know if works
  5 件のコメント
Enrico Gambini
Enrico Gambini 2022 年 2 月 2 日
If the pressure-temperature relation is univocal you can insert only the temperature. I edited
Samuel Ofosu-Yeboah
Samuel Ofosu-Yeboah 2022 年 2 月 2 日
It worked perfectly!!
You have been so helpful!
Thank you for your time.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by