m file code sometimes loss a "end" and corruput the file on hard disc.
1 view (last 30 days)
Show older comments
I encountered some very rare error (~1 occurance/year).
The error is that when I run matlab project/functions, very rarely the code is corrupted, one time it is a variable name that was changed at somewhere which cause an error(The old variable name is updated, and run for many times OK, then suddenly error take place one day saying that a variable is not defined), the other time is the lossing of a "end" statement in middle, so the code jump to the FUNCTION END and cause error of no argout.
This is strange since I have not edit this code for many months but still using it everyday. But it just happened just now.
I thought it might be caused by too heavy usage of my xps13 laptop for past 7 years. I used Matlab too heavily to automate my enumourous works and my laptop seems to be at the final stage of its life.
Not sure if someone else also encountered this kind of problem.
1 Comment
Rik
on 23 Mar 2022
I don't see what would make this question not appropriate. Can you explain why you think it is?
Accepted Answer
Jan
on 23 Mar 2022
Edited: Jan
on 23 Mar 2022
It is extremely unlikely, that the 3 characters "end" vanish inside a text file, while the rest of the computer runs without a crash. Such behaviour would be a sign of pure magic.
This effect happens frequently and you find many similar questions. In all (!) cases, there have been deterministiv reasons, which the user was not aware of. Of course, this does not allow to prove, that this is true in your case alos, but it is a very strong evidence.
Compare the changed files with your backups. Check, when these files have been changed or if you have several files with the same name and are running another version, because the current directory is the folder, which contains the other M file.
If the 3 characters "end" would be changed to some strange uni-code characters, a failing SSD or hard disk would be more plausible. But a clean vanishing is too unlikely.
Use a chkdsk (assuming you work with Windows) and a tool like CrystalDiskInfo to check the integrity of the disk. But have in mind, that there is another important source of problems, which you did not consider yet. A version history, which contains all changes of each file, is required for a reliable programming.
More Answers (0)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!