Plotting the theoretical maximum possible efficiency of a heat engine

4 ビュー (過去 30 日間)
Aidan Palermo
Aidan Palermo 2022 年 9 月 5 日
編集済み: David Goodmanson 2022 年 9 月 6 日
I'm trying to create a temperature vs. efficiency plot using the equation n=1-(Tl/Th) for 3 different Tl values.
clear all
close all
n=0;
Tl1=263;
Tl2=277;
Tl3=291;
for Th=299:.1:316
n=n+1;
TME(n)=1-(Tl1/Th(n));
TME2(n)=1-(Tl2/Th(n));
TME3(n)=1-(Tl3/Th(n));
end
Matlab keeps telling me "index exceeds the number of array elements" and Th only eqauls 299.1 instead of the whole range it is supposed to run through. Can anybody tell me what I'm doing wrong here?

回答 (1 件)

David Goodmanson
David Goodmanson 2022 年 9 月 6 日
編集済み: David Goodmanson 2022 年 9 月 6 日
Hi Aidan,
It's possible to fix up the for loop, but easier and much more in the spirit of Matlab to do this with vectors.
Tl1=263;
Tl2=277;
Tl3=291;
Th=299:.1:316;
TME = 1 - (Tl1./Th);
TME2 = 1 - (Tl2./Th);
TME3 = 1 - (Tl3./Th);
Here the use of ./ means that Th is divided into the numerator on an element-by-element basis, so for e.g. TME you get a vector the same length as Th.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by