- Author:
- aram148 <42922407+aram148@users.noreply.github.com>
- Date:
- 2022-07-22 15:40:16+12:00
- Desc:
- Added type up of muscle model
- Permanent Source URI:
- https://models.physiomeproject.org/workspace/6b0/rawfile/d39d197151fcd8e3935a13c0c200987bbb41cd15/peripheral_airway/Peripheral_matlab/createSymmTMatrix.m
% A function that will compute the necessary transformation matrix, T,
% that maps all
% This function will be structured as a recursive function, with the base
% case being the trivial 3-branch case (order 2)
% DATE: 22/02/17
% AUTHOR: Austin Ibarra
% VERSION: 1.0
% == LOG CHANGE == %
function T = createSymmTMatrix(order)
%% Initialise the matrix
numBr = 2^order - 1;
numRows = (numBr - 1)/2;
numCols = (numBr + 1)/2;
V = zeros(numRows,numCols);
%% Perform the looping
numElem = 2; % Start off with 1/2, when filling out the matrix
count = 0;
row = 1; % The current row that we are on
i = 1;
while i <= numCols % loop along the columns
V(row,i) = 1/numElem;
count = count + 1;
if i == numCols
% Check if we have reached the end of the matrix columns. If yes,
% then check if we are on the last row, and if we are, then
% terminate the loop.
if row == numRows
break
else
% Otherwise, it means that we need to move onto the next row,
% reset count, and double numElem.
row = row + 1;
count = 0;
i = 1;
numElem = numElem*2;
end
else
i = i + 1;
end
if count == numElem
row = row + 1; % Move onto the next row
count = 0; % Reset count back to zero
end
end
%% Now, concatenate the matrices together to form T
I = eye((numBr + 1)/2);
ZERO = zeros(numBr,(numBr - 1)/2);
T = cat(2,cat(1,I,V),ZERO);
end