Syntax
r=randminv(r,c,[rmin])
Input Parameter
r : | | rows |
c : | | cols |
rmin : | | minimal value or [rmin rmax]; default is [rmin 1] |
Output Parameter
Copyright 2018-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, randminv
, generates a random matrix with specified dimensions and a minimum value. It is part of the SolidGeometry library and was introduced in version 4.4.
Input Parameters
- r: Number of rows in the output matrix.
- c: Number of columns in the output matrix.
- rmin: A scalar or a two-element vector specifying the minimum value or range [rmin, rmax] for the random values. The default range is [rmin, 1].
Output
- r: A random matrix with dimensions specified by the input parameters and values within the specified range.
Algorithm Steps
- Check the number of input arguments using
nargin
. If only one argument is provided, set varargin{1}
to r
, and default r
and c
to 1.
- Retrieve the minimum value or range using
getfuncparams
with a default of 0 if not specified.
- If
rmin
is a scalar, convert it to a two-element vector [rmin, 1]
.
- Generate a random matrix
r
with dimensions (r, c)
using the rand
function.
- Scale and shift the random values to fit within the specified range
[rmin(1), rmin(2)]
using the formula: r = r * (rmin(2) - rmin(1)) + rmin(1)
.
Algorithm explaination created using ChatGPT on 2025-08-18 22:25. (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