replacemat

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

replaces values in vectors and matrices

Description

mainly: A(A==valold(i))=valnew(i)
tab(mat)

Example Illustration

 missing image of replacemat(A,valold,valnew)

Syntax

replacemat(A,valold,valnew)

Input Parameter

A: vectors or matrices
valold: existing values
valnew: new values

Examples


A=[1 2 3; 4 5 6], replacemat(A,1,9)
A=[1 2 3; 4 5 6], replacemat(A,[1 9],[9 0])




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 algorithm is a MATLAB function named replacemat that replaces specific values in a vector or matrix with new values. It is part of the SG-Library and was created by Tim Lueth in 2017.

Input Parameters

Algorithm Steps

  1. The function iterates over each element in the valold vector using a for-loop.
  2. For each element valold(i), it finds all occurrences of this value in the matrix or vector A.
  3. It replaces each occurrence of valold(i) in A with the corresponding value valnew(i).

Example Usage

Consider a matrix A = [1 2 3; 4 5 6]:

Algorithm explaination created using ChatGPT on 2025-08-18 22:01. (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