openinmatlabeditor

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - File handling
Introduced first in SolidGeometry 5.0, Creation date: 2020-10-29, Last change: 2025-09-15

same as opentoline but creates a file if not existing



See Also:

Example Illustration

 missing image of openinmatlabeditor (fname,ln)

Syntax

openinmatlabeditor(fname,[ln])

Input Parameter

fname: file name
ln: line for cursor

Examples


openinmatlabeditor('test.txt',4)




Copyright 2020-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 openinmatlabeditor that is designed to open a specified file in the MATLAB editor. If the file does not exist, it creates the file. The function is part of the SolidGeometry library and was introduced in version 5.0.

Input Parameters

Algorithm Steps

  1. The function begins by calling getfuncparams to retrieve the line number ln from the variable arguments. If no line number is provided, it defaults to 1.
  2. It uses the which function to determine the full path of the file specified by fname.
  3. If the file path pname is empty, it checks if the file exists using exist(fname).
  4. If the file does not exist (i.e., exist(fname)~=2), it creates the file using fopen with write permissions and US-ASCII encoding, then immediately closes it with fclose.
  5. If the file exists, it calls opentolineTL with the file name and line number to open the file at the specified line.
  6. If the file path pname is not empty, it calls opentolineTL with the full path and line number to open the file at the specified line.

The function ensures that the specified file is opened in the MATLAB editor, creating it if necessary, and positions the cursor at the desired line.

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