Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8186399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:10:58+00:00 2026-06-07T02:10:58+00:00

I have a written a MATLAB program that creates custom MATLAB functions on the

  • 0

I have a written a MATLAB program that creates custom MATLAB functions on the fly and launches them in other MATLAB instances using unix command. I use this program for automatizing fMRI neuroimaging analyses (using SPM8 for MATLAB), and everything works fine. However, MATLAB imposes a function name length maximum of 63 characters (namelengthmax). As I need to save two different timestamps in each function name together with the name of the function that created it (I have several different functions that create these new functions that are used for multithreaded fMRI analysis), 63 characters is quite limiting for filenames like:

atf_2012_07_05_18_01_02_specify_1st_level_2012_07_05_18_10_15.m

In this example atf means ‘analysis thread function’ (to separate it from other files with similar filenames), the first timestamp identifies the run (a global timestamp, it this case 5th of July 2012 at 18:01:02), then there’s a string specify_1st_level that identifies the function (in this case specify_1st_level.m) that created this new ‘analysis thread function’, and then the second time stamp identifies this specific new ‘analysis thread function’ from other new ‘analysis thread functions’ created to be run in other threads (and for different analysis subjects, or for different analyses) and that are run simultaneously.

My problem is the character limit of 63 characters for function names.

I’m aware that I could write my timestamps without underscores (_), or compress them, and I can make my function names shorter (eg. specify_1st_level.m -> sp1st.m), and also I could divide my functions created on the fly in different subfolders also created on the fly named eg. with global timestamps. Edit: Or I could even create a hash of the entire function name and use the hash as a function name instead of the human-readable string presented above.

However, I plan to add more data in the names of ‘analysis thread functions’ (one or more hash values of different analysis parameter sets used in this run to identify identical analyses of different times). If possible, I would like to keep it nice and simple (human-readable function names help in debugging of ‘analysis thread functions’ created on the fly).

So, is there any way to extend namelengthmax ? I’m running MATLAB R2012a in Linux. I’m also happy to hear any other ways to solve this issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:11:00+00:00Added an answer on June 7, 2026 at 2:11 am

    Answering to my own question: After thinking it some more, I found a way to embed as much information as I want into a MATLAB function name and still keep it readable for humans. First, I’ll compute SHA1 hash of my function filename: SHA1 hash of atf_2012_07_05_18_01_02_specify_1st_level_2012_07_05_18_10_15.m is E545831A 0002C73B CA095F11 25FC5C51 35B82451 (here presented with spaces for clarity).

    Then my function name will be [ 'atf_', sha1hashString, '.m' ], for this example that’ll be atf_E545831A0002C73BCA095F1125FC5C5135B82451.m, so the function name length will be 44 characters, that’s no problem at all. This solves the limitation of 63 characters, but I also need a way to be able to find my functions using regular bash commands.

    So I’ll create a copy of that function file, concatenating the hash to the end of the original function name, so it becames atf_2012_07_05_18_01_02_specify_1st_level_2012_07_05_18_10_15_E545831A0002C73BCA095F1125FC5C5135B82451.m. Then I can find the correct function easily in bash using ls or find (for debugging purposes), check the hash from the end of the filename and set breakpoint in MATLAB debugger in the function that will be called from MATLAB (eg. atf_E545831A0002C73BCA095F1125FC5C5135B82451.m) and use MATLAB debugger without problems.

    This is the most practical solution I can think of and it makes possible to add hashes of analysis parameter sets into the function name too: I’ll just compute the SHA1 hash of the analysis parameter set (let’s assume that the SHA1 hash of the parameter set is A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D, and concatenated with original function name it’ll be atf_2012_07_05_18_01_02_specify_1st_level_2012_07_05_18_10_15_A9993E364706816ABA3E25717850C26C9CD0D89D.m. Then I’ll compute a new SHA1 hash of this original function name extended with the SHA1 hash of the analysis parameter sets: SHA1 hash of atf_2012_07_05_18_01_02_specify_1st_level_2012_07_05_18_10_15_A9993E364706816ABA3E25717850C26C9CD0D89D.m is A81F0083 38868103 F1A0DB69 010279D5 5DB3751E. Then I’ll create two identical functions, one for MATLAB and one for my debugging purposes, and they will be named atf_A81F008338868103F1A0DB69010279D55DB3751E.m and atf_2012_07_05_18_01_02_specify_1st_level_2012_07_05_18_10_15_A9993E364706816ABA3E25717850C26C9CD0D89D_A81F008338868103F1A0DB69010279D55DB3751E.m. And it’s even possible to have several SHA1 hashes of different parameters sets in the same function name this way, eg. one defining the subjects to be included, other defining the data handling parameters etc., then concatenate both or all of them to the filename, and then compute SHA1 hash and write two identical functions as above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a Matlab GUI for my C program. I thought about using
I have written a set of Matlab functions and I want to distribute it
I have written some piece of code for my program in Matlab 7.10.0 which
I have a series of experiments that were written for MATLAB, but recently we
I have written a matlab project that takes a video as an input, cuts
I have written some matlab code for image analysis that searches for clusters in
I have some programs written in Matlab that I need to run several times
I have written a code in MATLAB that allows me to generate a random
I have written the following algorithm in order to evaluate a function in MatLab
I'm trying to rewrite code I've written in matlab in C++ instead. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.