Syntax
y=limitinterv(x,xlim)
Input Parameter
x : | | number |
xlim : | | [min max] |
Output Parameter
y : | | value between [min and max] |
Examples
limitinv(10,[5 20]), limitinv(-10,[5 20]), limitinv(30,[5 20])
Copyright 2023-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, limitinterv
, is designed to constrain a given number within a specified range. It is part of the SolidGeometry library, version 5.3, and was created by Tim C. Lueth in 2023.
Input Parameters
- x: A numerical value that needs to be constrained.
- xlim: A two-element vector specifying the minimum and maximum limits, in the form [min max].
Output
- y: The constrained value of
x
, which will be within the range specified by xlim
.
Algorithm Steps
- Check if
x
is less than the minimum limit xlim(1)
:
- If true, set
y
to xlim(1)
.
- Check if
x
is greater than the maximum limit xlim(2)
:
- If true, set
y
to xlim(2)
.
- If neither condition is met, set
y
to x
.
Example Usage
Here are some examples of how the function can be used:
limitinterv(10, [5 20])
returns 10, as it is within the range.
limitinterv(-10, [5 20])
returns 5, as -10 is below the minimum limit.
limitinterv(30, [5 20])
returns 20, as 30 is above the maximum limit.
Algorithm explaination created using ChatGPT on 2025-08-18 22:20. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21