summaryrefslogtreecommitdiffstats
path: root/Kod/bilbana/yc4/clamp.m
diff options
context:
space:
mode:
authorGustav Sörnäs <gusso230@student.liu.se>2019-11-27 17:56:01 +0100
committerGustav Sörnäs <gusso230@student.liu.se>2019-11-27 17:56:01 +0100
commit3471a2ad09670ce409ed9009254ebf0801c0d586 (patch)
tree66e61a91e2ead8976720be8d2359b62ab5746844 /Kod/bilbana/yc4/clamp.m
parent40258c7d594d85eb3b7d75c059ad5223372ba5ae (diff)
parent2246ff7466c252dff4e22ed894dee3f152f0f4e1 (diff)
downloadtfyy51-3471a2ad09670ce409ed9009254ebf0801c0d586.tar.gz
Merge remote-tracking branch 'origin/display-graphs'
Diffstat (limited to 'Kod/bilbana/yc4/clamp.m')
-rw-r--r--Kod/bilbana/yc4/clamp.m6
1 files changed, 6 insertions, 0 deletions
diff --git a/Kod/bilbana/yc4/clamp.m b/Kod/bilbana/yc4/clamp.m
new file mode 100644
index 0000000..78ddedd
--- /dev/null
+++ b/Kod/bilbana/yc4/clamp.m
@@ -0,0 +1,6 @@
+function val = clamp(n, m, M)
+% returns n if n is between m and M, otherwise
+ % m if n < m
+ % M if n > m
+val = min(max(n, m), M);
+end