How can i form a filename from MATLAB identifier and correcting sntax error in "3dinvert.m"
조회 수: 6 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
Bjorn Gustavsson
2022년 1월 14일
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
Steven Lord
2022년 1월 14일
Function names must satisfy the same rules as variable names. Those rules are listed on this documentation page.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!