Syntax
c=colofn(i,[colbar,colstr])
Input Parameter
i : | | integer number |
colbar : | | order of colors; default is 'kbgcmyrw' |
colstr : | | colorstring such as 'R*--' |
Output Parameter
Examples
colofn(4)
colofn(4,'kymg')
colofn(4,'kymg','r--')
colofn(4,'kymg','--')
Copyright 2015-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, colofn
, is an auxiliary procedure designed to return a color character for a given integer input. It is part of the SolidGeometry library and was introduced to provide a simple way to handle colors in loops.
Input Parameters
- i: An integer number that determines the color to be selected from the color bar.
- colbar: A string representing the order of colors. The default value is 'kbgcmyrw', which stands for black, blue, green, cyan, magenta, yellow, red, and white.
- colstr: A color string that can include additional formatting, such as line styles or markers (e.g., 'R*--').
Output Results
- c: A color character string that represents the selected color, potentially modified by the
colstr
parameter.
Algorithm Steps
- Initialize
colbar
to 'kbgcmyrw' unless a different order is provided as the second argument.
- Initialize
colstr
to an empty string unless a specific color string is provided as the third argument.
- Calculate the length of
colbar
and store it in n
.
- Use the
mod1
function to determine the index i
within the bounds of colbar
.
- Select the color character from
colbar
using the calculated index i
.
- If
colstr
is not empty, replace its first character with the selected color character and assign it to c
.
- If no output is expected (
nargout==0
), create a figure and plot using the selected color.
Example Usage
colofn(4)
: Returns the 4th color from the default color bar.
colofn(4,'kymg')
: Returns the 4th color from the custom color bar 'kymg'.
colofn(4,'kymg','r--')
: Returns a color string starting with the 4th color from 'kymg', followed by '--'.
colofn(4,'kymg','--')
: Returns a color string starting with the 4th color from 'kymg', followed by '--'.
Algorithm explaination created using ChatGPT on 2025-08-19 01:30. (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