copyplot

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - User interface
Introduced first in SolidGeometry 3.5, Creation date: 2017-03-05, Last change: 2025-08-26

copies the content of one figure into a random one

Description

This functions helps to save figure content of figures that will be closed into another one

See Also: copyfig , snapplot , smbdrawnow

Example Illustration

 missing image of copyplot

Syntax

copyplot

Examples


close all; SGfigure(SGsample(27)); view(-30,30);
copyplot




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 MATLAB function, named copyplot, is designed to copy the content of the current figure window into a new, randomly numbered figure window. It is part of the SolidGeometry library and was introduced in version 3.5. The function is useful for saving the content of figures that are about to be closed.

Input Parameters

The function copyplot does not take any input parameters. It operates on the current figure window, which is accessed using the gcf (get current figure) command.

Algorithm Steps

  1. Retrieve the handle of the current figure using a = gcf;.
  2. Capture the current figure's content as an image using I = getframe(gcf);. This stores the figure's content in the variable I, which contains the image data in I.cdata.
  3. Create a new figure window with a random number as its identifier using figure(round(rand*10000));. The rand function generates a random number between 0 and 1, which is then multiplied by 10,000 and rounded to the nearest integer to create a unique figure number.
  4. Display the captured image data in the new figure window using imshow(I.cdata);. The imshow function is used to display the image data stored in I.cdata.
  5. Return focus to the original figure window using figure(a);. This ensures that the original figure remains the active window after the function executes.

Output

The function does not return any output variables. Instead, it creates a new figure window displaying the content of the original figure.

Use Case

The function is particularly useful when you want to preserve the content of a figure that is about to be closed, allowing you to continue working with the original figure while having a copy available for reference or further manipulation.

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