diff options
Diffstat (limited to 'Part 3/scripts/get_function.m')
-rw-r--r-- | Part 3/scripts/get_function.m | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Part 3/scripts/get_function.m b/Part 3/scripts/get_function.m new file mode 100644 index 0000000..1e1fb8f --- /dev/null +++ b/Part 3/scripts/get_function.m @@ -0,0 +1,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, 1) = 2*i; + else + y(count, 1) = 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 + |