Syntax
r=randol([r,c,rmin])
Input Parameter
r : | | rows or minimum number |
c : | | col |
rmin : | | minimum number; default is 0.01 |
Output Parameter
r : | | randum number, or matrix |
Examples
randol(4,4,.2) % 4x4 matrix, numbers between [0.2 and 0.3[
Copyright 2020-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 algorithm generates random numbers with a specified minimum value, useful for creating random overlap intervals. It is part of the SolidGeometry library.
Input Parameters
- r: Number of rows for the output matrix or the minimum number if only one argument is provided.
- c: Number of columns for the output matrix.
- rmin: Minimum value for the random numbers. Default is 0.01.
Output
- r: A random number or a matrix of random numbers.
Algorithm Steps
- Retrieve the input parameters using the function
getfuncparams
for r
, c
, and rmin
.
- If only one argument is provided, set
rmin
to r
and r
to 1.
- Calculate
i
as 10^floor(log10(rmin))
to determine the order of magnitude of rmin
.
- If
rmin
is a scalar, convert it to a range by setting rmin
to [rmin+0.1*i, rmin+0.99*i]
.
- Generate a matrix of random numbers with dimensions
r
by c
using rand(r,c)
.
- Scale and shift the random numbers to fit within the range specified by
rmin
.
This function is particularly useful for generating random numbers that need to be within a specific range, ensuring a minimum value is respected.
Algorithm explaination created using ChatGPT on 2025-08-18 23:34. (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