Clear Filters
Clear Filters

How can i form a filename from MATLAB identifier and correcting sntax error in "3dinvert.m"

3 views (last 30 days)
In attempt to run a code i got this error responses
1)
335- fclose(fid);
Line 335:Filename 'C:\Matlab\3dinvert.m' if not formed from a valid MATLAB identifier
2)
Syntax error:"3dinvert.m cannot run as it appears
3dinvert
Enter input arguments by typing it now,then press Enter to run. The values you enter will be set as deffaul input when you click the Run button in future.
Please, what is your advice
Thank you
Femi

Answers (1)

Bjorn Gustavsson
Bjorn Gustavsson on 14 Jan 2022
There are restrictions of the filenames for matlab-functions, and as far as I recall it is supposed to not start with a number (I couldn't quickly find the documentation for this, but you should be able to search for this. In my work I also stay away from leading "_", so start with [A-Za-z]). So try to put the number somewhere but in the leading place. Also make good use of the fullfile, filesep and fileparts functions - they will make your functions and scripts more portable across different OSes (this might seem like a remote consideration from your perspective - but if you're lucky and your programmes becomes useful enough this is a major gain when you get users on all sorts of environments...).
HTH
  3 Comments

Sign in to comment.

Products


Release

R2015b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!