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

3 visualizaciones (últimos 30 días)
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

Respuestas (1)

Bjorn Gustavsson
Bjorn Gustavsson el 14 de En. de 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 comentarios
Steven Lord
Steven Lord el 14 de En. de 2022
Function names must satisfy the same rules as variable names. Those rules are listed on this documentation page.

Iniciar sesión para comentar.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by