Using Matlab solve the following In thermodynamics the Carno

Using Matlab, solve the following:

In thermodynamics, the Carnot efficiency is the maximum possible efficiency of a heat engine operating between two reservoirs at different temperatures. This efficiency, n, is defined as:

n = 1-Tc/Th

where Tc and Th are the absolute temperatures of the cold and hot reservoirs, respectively. Instead of user inputs, use the following relationships for the absolute temperatures.

Tc = 275 + randi(150) Kelvin

Th=300+randi(400) Kelvin

Your code should error-check the values such that Th is greater than Tc and switch the two if needs as Th should be greater than Tc, then calculate the maximum efficiency. You should also make sure that the two temperatures are not within 50 degrees of each other, repeat the random number sequence until this is the case.

Solution

a= 1; % counter
while a<200 % to limit the iterations to 200 times
   T1 = 275 + randi(150); %Kelvin
   T2 =300+randi(400) ; % Kelvin
   if T1 > T2
       Th = T1; Tc = T2;
   else
       Th = T2; Tc = T1;
   end
   if (Th-Tc >50 )
       n = 1- (Tc/Th);
       fprintf(\'Efficiency is %d\ \', n)
       break % comes out of while loop
   end
   a = a+1; % update the counter
end

Using Matlab, solve the following: In thermodynamics, the Carnot efficiency is the maximum possible efficiency of a heat engine operating between two reservoirs

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site