tryuigetfile

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

give the user a try to select a file

Description

This function is useful if numerical parameter xy are generated by analyzing a file. If xy is not numerical or xy is empty or xy is a non existing file, an user dialog is opened to select a file. The final result is a valid file name or empty or the numerical parameter xy.
The final result is only empty if no file was selected.

See Also:

Example Illustration

 missing image of tryuigetfile(xy,fselect)

Syntax

xy=tryuigetfile(xy,[fselect])

Input Parameter

xy: numerical parameter, empty or existing filename
fselect: such as '*.avi;*.m4v;*.mp4;*.mov;*.mpg'; default is *.*

Output Parameter

xy: numerical parameter, empty or existing filename

Examples


tryuigetfile(12)
tryuigetfile('')
tryuigetfile('notexistingfile.avi')




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, tryuigetfile, is designed to handle file selection in MATLAB. It is particularly useful when numerical parameters are generated by analyzing a file. The function checks if the input is a valid file or directory, and if not, it prompts the user to select a file through a dialog box.

Input Parameters

Output Results

Algorithm Steps

  1. Initialize fselect to '*.*'. If a second argument is provided and is not empty, update fselect with this value.
  2. Check if xy is not numeric and if it is either empty or not an existing file or directory. This is done using the exist function to verify the file or directory existence.
  3. If the conditions in step 2 are met, open a file selection dialog using uigetfile with the filter fselect.
  4. Concatenate the selected path and filename into xy.
  5. If the length of xy is zero, set xy to an empty array.
  6. Check if xy is not empty and if it does not exist as a file. If so, set xy to an empty array.

Example Usage

Algorithm explaination created using ChatGPT on 2025-08-19 07:15. (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