uniquehist

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.1, Creation date: 2017-08-30, Last change: 2025-09-14

performs the unique command and creates a full histogram count afterwards

Description

works exactly as unique but calculates the number of occurences afterwards

See Also:

Example Illustration

 missing image of uniquehist(A,)

Syntax

[C,ia,ic,h]=uniquehist(A,[])

Input Parameter

A: array A

Output Parameter

C: unique arrary, may be sorted
ia: index vector ia
ic: index vector ib
h: number of entities of C in A

Examples


L=1+floor(rand(10,1)*10)
L=1+floor(rand(100,2)*10)
[a,~,~,h]=uniquehist(rounddiv(ELunsort(L),2),'rows'),[a h]
uniquehist(rounddiv(ELunsort(L),20))
uniquehist(rounddiv(ELunsort(L),20),'rows')




Copyright 2017-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, uniquehist, is an extension of the MATLAB unique function. It identifies unique elements in an array and calculates the frequency of each unique element.

Input Parameters

Output Results

Algorithm Steps

  1. Call the unique function with input array A and any additional parameters to get unique elements C, and index vectors ia and ic.
  2. Check if the 'rows' option is specified in varargin. If so, set rows to true.
  3. Initialize a zero vector h with the same number of rows as C to store histogram counts.
  4. Iterate over each unique element in C:
  5. If no output arguments are specified, plot the results using a custom plotting function.
Algorithm explaination created using ChatGPT on 2025-08-19 01:37. (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