Anonymous Functions Question using Heat

Energy required to heat water at constant pressure is approximately :
E=m * Cp(delta T)
m=mass
Cp= heat capacity of H2O 1cal/gK
delta T= change in temperature
Create an anonymous function called heat to find energy required to heat 1 gram of H2O if change in temp is provided as the input
g [(cal 1)/(g K)] K = cal
Joules are the units of energy used most often. Create another anonymous function cal_to_J to convert your answer to Joules (4.2 J/ cal)
Save your anonymous function to a .mat file.
This is what I have so far:
heat=@(g,T) g.*T;
heat
heat(1,T)
cal_to_J=@(ans) ans.*4.2
cal_to_J
cal_to_J(ans)
Any help would be appreciated, thank you!!

3 件のコメント

Walter Roberson
Walter Roberson 2013 年 11 月 27 日
What difficulty are you observing?
Note: it is not a good idea to use "ans" as the name of a variable!
philip colby
philip colby 2015 年 6 月 16 日
I think it is because you defined your function as t but typed T in your formula
Walter Roberson
Walter Roberson 2015 年 6 月 16 日
The poster never used "t". The poster did, though, try to call heat(1,T) in a context where T is not defined

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFluid Network Interfaces Library についてさらに検索

質問済み:

2013 年 11 月 27 日

コメント済み:

2015 年 6 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by