-
Notifications
You must be signed in to change notification settings - Fork 0
/
PVB302_A1_B.m
36 lines (30 loc) · 943 Bytes
/
PVB302_A1_B.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
%---------------------------------------%
% PVB301 - Assignment 1: Thermodynamics %
% Author: Waldo Fouche, n9950095 %
%---------------------------------------%
clear; % Testing only
% Question 1 - Part B
compartments = 15; % Compartments
up = 15; % Eyes Up
down = compartments - up; % Eyes Down
% Define Arrays:
d = transpose(0:1:compartments); % Eyes Down
u = transpose(compartments:-1:0); % Eyes Up
BC = transpose(zeros(1,compartments+1)); % Store Microstates
i = 1; % Counter
m_total = 0; % Microstate Counter
% Calculate BC of Each microstate and Compute Total # of states.
while i<compartments+1
fu = factorial(u(i));
fd = factorial(d(i));
fc = factorial(compartments);
bc = fc./(fu*fd);
BC(i) = bc;
i = i+1;
m_total = m_total + bc;
end
% Display Data in Table
T = table(u,d,BC);
T.Properties.VariableNames = {'Eyes Facing Up','Eyes Facing Down','# of Microstates'};
disp(T);
disp(m_total);