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.
Related
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.
I am using pywinauto to open a file in some software. My code is supposed to open a specific file using the Open dialog:
import pywinauto
from pywinauto.application import Application
app = Application(backend="uia").start(cmd_line="C:\\Program Files (x86)\... etc")
app.Dialog.Close.click()
app.FORAM3.Derivative.OpenSpectrum.click()
app.FORAM3.Open.Edit.SetEditText(r"C:\\Users\... etc")
The code opens the software and clicks the "Open Spectrum" button, where it gets the standard Open dialog:
on the line app.FORAM3.Open.Edit.SetEditText("Paracetamol 4.foram") I get a pywinauto.findwindows.ElementNotFoundError which states that it could not find an element or a method called SetEditText.
I have already looked around on the internet and cannot find any solutions.
How to open an existing file using pywinauto from SourceForge says to use app.Open.Edit.SetEditText.
I tried using app.Open.Edit, removing the "FORAM3" part, and it could not find "Open".
I replaced this with app.Dialog.Edit and it gave me the original ElementNotFoundError.
I also looked at Open an existing excel workbook using pywinauto, however the answer to this question suggests opening the file within excel itself, which does not apply to me.
I even tried replacing SetEditText with TypeKeys and got AttributeError: Neither GUI element (wrapper) nor wrapper method 'TypeKeys' were found (typo?)
One answer in another question, "Open file from windows file dialog with python automatically", suggests to use pywinauto and gives the following code:
from pywinauto import application
app = application.Application().start_('notepad.exe')
app.Notepad.MenuSelect('File->Open')
# app.[window title].[control name]...
app.Open.Edit.SetText('filename.txt')
app.Open.Open.Click()
I tried again using SetText and again got the AttributeError saying that it could not find an element or method with that name.
The accepted answer for this particular question says to use ctypes. I may resort to this if I cannot find a solution in pywinauto. The question has also been suggested as a possible duplicate of Choosing a file in Python with simple Dialog so I looked at that.
The accepted answer here suggests to use Tkinter. The other two suggest easygui and Zenity. Not what I'm after. There are no mentions of pywinauto in the other answers.
I am not asking how to open a file. From the answers I've looked at I can clearly see how to do it. My question is: Why isn't it working? It's clear that my code isn't recognising any of these Methods that have been suggested, so there must be something else wrong.
I started using Inspect.exe.
Part of the hierarchy has a Pane with an empty string for a name. This could be the problem, however I've worked on other software with empty panes in. In those cases I have been able to ignore the empty panes and still use the child controls. There are also three different controls with the name "Filename" which could be an issue, however since I have referred to the Edit control, it can only be one of them. I did a quick check to see whether I had to refer to the Edit control as a child of the combo box, used the line app.Dialog.combobox.Edit.SetText, and got the same AttributeError again.
My final attempt at fixing the problem was to try a different console. I have been running my code in PyCharm and found a question on jetbrains asking if it was possible to run code from PyCharm in an external console, stating that the PyCharm console did not have the same low-level control that the windows cmd.exe has.
I ran my code in the IDLE shell, and got the same error:
I tried running the code in the regular python command prompt, and it closes with the same error. This seems enough evidence to suggest that PyCharm itself isn't the issue here.
So, to reiterate: Why doesn't python recognise any Edit control methods?
backend="uia" provides different hierarchy and different method names (sometimes). Default backend is "win32" so old Notepad examples are not always relevant for "uia" backend. Also old CamelCase methods are deprecated in 0.6.5 and they even exist in "win32" backend only. Use PEP-8 method names for "uia" backend like set_text. And upgrade by pip install -U pywinauto.
I am looking for a macro command to open .im files in FIJI.
Since FIJI does not support the .im format, it requires a plugin called OpenMIMS, but simple lines:
run("Open MIMS Image");
open(" directory ");
would give an error message:
File is not in a supported format, a reader plugin is not available, or it was not found.
An almost the same question has apparently been asked and solved here-
Problems with an ImageJ plugin, except I am already using FIJI and Bio-Formats would not be a solution to my problem as it does not seem to support .im files, either.
I would much appreciate it if someone could enlighten me. =)
You should first check whether you can open the file using the menu via Plugins > Open MIMS Image. (I assume you installed the OpenMIMS plugin according to these instructions, adding an update site.)
When you do this while the macro recorder is running, it should record the necessary command to use in your macro code.
In the lines you posted, the second line:
open(" directory ");
doesn't make any sense and by itself will result in the error message you posted (have a look at the second part of the error message to find out the path that ImageJ is trying to open).
I have a Simulink model that uses an s_function, which is a mexw32 file. The s_function block uses a .lib module as well. Now, when I'm trying to run the model Matlab crash before the simulation end and without any errors in the command window. What are my options for debugging if Matlab crash?
This is typical behaviour of a badly written S-function that is causing a seg-fault. Debug it using the steps outlined at: http://www.mathworks.com/support/solutions/en/data/1-3KK6RK/
I dont know about Simulink or S-functions (never used them), but usually when a MEX-file segfaults, MATLAB will recover from it most of the times, showing a stack trace and placing you in the "you need to restart MATLAB" command prompt mode. You'll find a crash dump and error log files in the system %TMP% folder.
As other have said, if you have access to the source code of the MEX-function, recompile it with debugging symbols, attach a debugger to MATLAB, place breakpoints in the debugger, and initiate the MEX-function by calling it from MATLAB. Once inside the C code, debug it code step by step until you find the problem.
Here is the relevant doc page describing this process in more details.
You mentioned that your MEX-executable is linked against an external library. So you might also want to check that for the source of the problem.
I am creating a .dat file with headers and data in Matlab, however when I try opening it from the folder where it is saved then I get the error that says 'file in use by another application and cannot be accessed'. This error occurs even when Matlab is closed. I can only open it as a text by right clicking on the file through the Matlab's current directory window. Why is this happening and how to resolve it?
You could try:
fclose('all')
to close all open files.
This is not supposed to happen, and, in fact, doesn't happen when I try your code on my machine (OS X, R2010a). In other words, I strongly doubt that there is any problem with the Matlab code.
Try restarting Windows, then the problem should go away for newly created, differently named files.