aboutsummaryrefslogtreecommitdiffstats
path: root/Part 3/scripts/get_function.m
blob: b34ee30a3085c97eef90d565851c915eb56c4361 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function y = get_function(N, h, f)

y = 0:N;

if f == 1
    count = 1;
    for i = 0:h:1
        if i < 0.5
            y(count) = 2*i;
        else
            y(count) = 2-2*i;
        end
        count = count + 1;
    end
elseif f == 2
    y = sin(2*pi*(0:h:1));
else
    y = abs(sin(2*pi*(0:h:1)));
end

end