-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeb.m
More file actions
46 lines (40 loc) · 831 Bytes
/
Copy pathmakeb.m
File metadata and controls
46 lines (40 loc) · 831 Bytes
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
36
37
38
39
40
41
42
43
44
45
46
function b = makeb(I)
nDimI = ndims(I);
switch nDimI
case 1
m = length(I);
ut = triu(ones(m-1, m-1));
b = makeb1D(I, ut);
case 2
[m, ~] = size(I);
ut = triu(ones(m-1, m-1));
b = makeb2D(I, ut);
case 3
[m, ~, ~] = size(I);
ut = triu(ones(m-1, m-1));
b = makeb3D(I, ut);
otherwise
error('Improper size of I');
end
end
function b = makeb1D(I, ut)
m = numel(I);
b = zeros(m,1);
b(1:m-1) = ut * I(1:m-1);
end
function b = makeb2D(I, ut)
[m, n] = size(I);
b = zeros(m, n);
for i = 1:n
b(:, i) = makeb1D(I(:,i), ut);
end
end
function b = makeb3D(I, ut)
[m, n, p] = size(I);
b = zeros(m, n, p);
for i = 1:n
for j = 1:p
b(:,i,j) = makeb1D(I(:,i,j), ut);
end
end
end