J Collins
J Collins

Reputation: 2170

How to manage MATLAB and Simulink filenames?

I am discovering something that is, quite frankly absurd, about MATLAB. It is not possible in a session of MATLAB to open two files or even reference by link two files with the same name, even if in different folders (as would re required by any file system.) In fact it isn't possible to have two identically named files accessible on the MATLAB path without leading to ambiguity when addressing files.

In my quite large solution I have resolved to giving the full name of the file, inclusive of its location in the model, to allow unique file names and not violate this limitation. Up to now this has resolved the issue in a somewhat ugly way. However I have just now discovered a second issue that compounds the first, that being file names are limited to 63 characters. Now I cannot have a name that fits either criteria and be sensible.

It seems the only answer is to choose semi-random file names that fit together into a global menagerie of file names and hope to capture just enough information to be able to identify a file and its purpose.

How else is one to manage large systems?

(Apologies for the tone, I am getting to the end of my tether with Mathworks software.)

Upvotes: 1

Views: 1166

Answers (2)

sebastian
sebastian

Reputation: 9696

That's the drawback of matlab's policy with the path and the "convenience" of putting thousands of files onto it.

If you're talking about "data-files" you're loading (via load) etc., then the solution is to use absolute path names. That's the proper way to do it anyway, imho.

You can use different functions with identical names, there are a few possibilities to do so:

  1. cd into the folder that contains the function you're wanting to call. That puts the function in the current directory to the "top" of the path. Not nice, but it works.
  2. Put different, equally named functions into packages and call them via package1.fun() package2.fun().
  3. Do things in an object-oriented manner. This reduces the raw number of m-files flying around dramatically.

Upvotes: 2

m_power
m_power

Reputation: 3204

From this link, the variable names are indeed limited to 63 characters. Filepaths aren't limited to 63 characters, so I don't see why you are having problems with giving the exact location.

Upvotes: 1

Related Questions