MATLAB runs prior iterations of file - matlab

Summary: MATLAB runs an earlier version of my code, despite having saved the new version.
When I run my code, MATLAB seems to run an older version of it. For example, I changed the print statement from "What is the name of the vector you wish to analyze?" to "Hello. How are you?", but it still runs the previous version of the code, despite the fact that I saved the file.
I have tried deleting all the files in the MATLAB "Current Folders" directory, and even opening new files for every small iteration of my code, but to no avail. I've tried searching for resolution to similar errors online, but this does not seem to have been documented previously. The only resource that even refers to this online seems to be this question, whose only resolution was that "The error message was misleading."
I would greatly appreciate any help. I am new to MATLAB, so please pardon any naive mistakes.

In all likelihood, there are two copies of the code, the one you are editing and the one you are running.
If the code you are trying to run is called "mycode", try typing which mycode. This will tell you the location of the code version that you are running. I would also recommend closing the editor window and typing edit mycode, which will open that version.
Note: From the screenshot, it appears that you are running MATLAB through a web browser and I don't know how that handles files.

Related

Dymola - Is there any difference between "Open" and "Load" files?

I’ve been using Dymola (version 2017) for three months and I’d just like to ask a simple issue that I think about it nearly every day. Is there any difference between the file tool “Open” and “Load"? I'm used to use Load for “load” the library packages and Open for “open” the model files, but I've tried to switch them few times and I didn’t notice any difference. I guess that it isn’t relevant and actually it’s just out of curiosity, but maybe someone in this community is able to shed some light on why there are two buttons. Thanks in advance.
Both load your .mo files into the package browser. But Open changes the working directory to the location of the .mo file, whereas Load does not.
From the command line:
openModel("lib.mo", changeDirectory=false) // corresponds to load
openModel("lib.mo") // corresponds to open
You can check your current working directory by typing cd on the command line.

VSCode Debugging with Mocha and ESM Breaking in ESM "compiled" File Instead of Original

I've been using the ESM module with VSCode and my Mocha unit tests for a long time now, a couple of years at least. Recently when I launch an individual test file in VSCode and set a breakpoint in the test file, it no longer breaks in the original file, but rather breaks in the "ESM compiled" file. I don't really know how ESM works enough to talk about it very well, but the file is compiled/transpiled/transformed in some way with all the imports converted to non-ESModule code. I'm able to step through, and it continues to step through other files as well, but each new file opened is this newly "ESM compiled" version instead of the original file, like it used to be. I only just noticed this recently. So I decided to install and older version of VSCode and see if it still happened, and it turns out it doesn't. With version 1.45.x it works as usual, but with anything newer, I get all these "ESM compiled" files opening up when I step through code.
Does anyone know why this is happening? Is there any new setting I can set in the newer VSCode versions that would cause this to not happen? It's really more of an annoyance than anything. I can still get my work done, but it's not as streamlined as it used to be. I will probably end up just downgrading permanently until I can find a way to make it not occur in the new version.
So, if anyone has experienced this, or knows of something new in VSCode that would cause this, I'd really appreciate some help. Thanks.

Octave 4.2 Command Window is Adding Blank Lines

First, I am new to Octave, but fairly familiar with Matlab. After using Octave for a short time I've noticed that the cursor in the command window will regularly add a new, empty line. Sometime this can be in the middle of typing a command. If I let the window sit with no input, the cursor will eventually advance all the way down the page and keep going.
I have never seen anything like this, and I do not know where to even begin to fix it.
Thanks!
Command Window Screenshot
My alternative answer is that that a bug report should be filed so that this issue gets fixed. I have the exact same problem. Every 30 seconds, when system time hits an even minute and 30 seconds past the minute, the command window cursor skips to the next line. One can still type to the command line and hit enter in the end. The command line now split at random points to several lines will be successfully computed. The problem is that you can not edit the line back past the inserted line break and the whole thing looks really messy. I tried to un-install and re-install but that did not help in my case. I use octave-4.2.1-w64-installer.exe
Boring solution (and hopefully permanent): I uninstalled and reinstalled the same version of Octave and this bug seems to have gone away. Not very convenient, but worked for me.
This might be a problem caused by a 3rd party application. I've seen this issue on a computer with Druva inSync. Disabling the Druva inSync service (not the client) stops this. inSync injects itself in applications using the Windows file dialog. Apparently this code contains a bug and accidentally writes a line feed (LF) to a file handle belonging to the application. The problem might also go away with a different Octave version. In particular the 4.2.x and 4.4.x seem to behave differently.

Matlab failed to open m file

I am new to matlab and I've installed it successfully. Everything works fine. But when ever I try to open .m files, I always get following error popping out of dialog box:
Error using open(line 162)
Failed to open matlab editor.
And in command window it throws a lot of Java exceptions.
First of all please forgive my poor English.
I've been searching for this problem all over the internet but couldn't find any useful solution.
I'm using windows 8.1 pro 64-bit os.
Your error message indicates that there is an error in a line that justs consists of
<br>
This is not valid matlab code (looks more like html). As such it seems like you have either messed up the open function, or overloaded it somehow.
I think the first thing to do is check which open and see where this points you.
If this does not help, try to look at the matlab path carefully and see whether you accidentally added a (html?) file on it called open.m.
Lastly, you could try to use the built in open function directly, check doc builtin for this. If you succeed at least you are sure it is not a matter of corrupting the standard file.

Groovy debugger out of sync

I am having a difficulty while attempting to debug some code in grails. It is difficult to put into text, so I have posted a screencast showing exactly what the problem is here. In short, while I am debugging the debugger starts jumping from place to place and not following the program logic I have in place. The only other similar question I have found is a year old, had no solution, and can be found here.
The best guess I have so far is that the debugger is displaying the text I have typed in, but is actually executing an older version of the class file which it has cached somewhere. Therefore, I tried:
cleaning the project
manually deleting all of the class files from the target folder and from the target-eclipse folder
Searching my entire hdd for additional files with similar names
removing my project from the workspace and re-adding it
closing and reopening the IDE
grails refresh-dependencies
Importing the project into a new IDE (I was using GGTS, I switched to IntelliJ)
None of those solutions had any effect. I realized that the issue was in a .groovy file, and I was writing almost pure Java, so I deleted the .groovy file, and re-created the class in a .java file. That solved my problem. Unfortunately I am having the problem again, and this time it is in a controller that heavily relies on the grails framework, so that solution is not an option. Other than also being in a .groovy file, another similarity is that the code breaks on an if statement.
My next steps:
Verify that the application is not executing the code I see by using print functions to monitor actual execution flow.
comment out the entire function and re-add functionality one line at a time to see if I can see what breaks it.
Delete the .groovy file, and re-create it as another .groovy file.
Any help is appreciated, and since I can't find any answers online I will continue to update this question as I learn more.
See my comment on the jira issue that you raised. You have found a problem with the groovy compiler and how it calculates line numbers. This is not a problem with executing the wrong class files or using a broken debugger. The debugger is doing exactly what it is expected to do. It is the compiler that is providing erroneous line number information.
The next step, as described in the issue, is to provide a simple project that recreates the bug. I tried to do so myself, but could not. So, please supply something that we can work with. Then we can notify the groovy compiler team.