duplicate matlab command window to gui - matlab

I am asking this question in reference to this post as I wasn't able to comment to the original post.
I used the code given in that post from #Hoki and mixed in my gui it is working fine. But sometimes i am getting following error
Error using test_gui>scroll_to_bottom (line 176)
Java exception occurred:
java.lang.IllegalArgumentException: bad position: 13319
at javax.swing.text.JTextComponent.setCaretPosition(Unknown Source)
Error in test_gui>commandWindowMirror (line 170)
scroll_to_bottom(h.f)
Error using test_gui>commandWindowMirror (line 166)
Java exception occurred:
javax.swing.text.BadLocationException: Invalid location
at javax.swing.text.GapContent.getChars(Unknown Source)
at javax.swing.text.GapContent.getString(Unknown Source)
at javax.swing.text.AbstractDocument.getText(Unknown Source)
at javax.swing.text.JTextComponent.getText(Unknown Source)
This always happens when I ask user to input something. My script ask users to enter some strings or values sometimes. But good thing is program doesnot crash it gives just error and when you press 'enter' again it returns to back position where it was stop. but scroll stops working and only when script is executed fully scroll comes to the last line. Any idea what might be causing this error and how to avoid it. Thank you.

Related

Adding a debug point as soon as an error appears MATLAB

this might be silly, Is there any way to automatically place a debug point when an error pops up in MATLAB
Error popping is done manually by
msg = 'Error has occurred'
error(msg)
What I need is, to automatically put a debug (not by manual intervention) after popping this error.
You can use dbstop with a condition:
dbstop if error
MATLAB pauses at any line in any file when the specified condition
occurs.

GWT Error Popup

The error popup with the following error message comes on the screen repeatedly when application is in idle state (no user activity is performed).
Error occurred on client: (TypeError): Unable to get property 'iterator_0' of undefined or null reference.
number: -2146823281
at handleEvent_206....EF34544...cache.html
at dispatchEvent_0..EF34544...cache.html
at sucess_184 ..
..
Can anyone give some pointers to navigate to the problamatic area in the code?
The fact that you're getting it repeatedly is probably due to the fact that you're performing an action on a timer (i.e. perform repeatedly an action).
From the small snippet you've shown, I don't think there's anything we can deduce. Do you have a larger stacktrace? It is still possible the error is in your own code (trying to invoke iterator() on a null object).

Multiple GPU code on Matlab runs for few seconds only

I am running the following MATLAB code on a system with one GTX 1080 and a K80 (with 2 GPUs)
delete(gcp('nocreate'));
parpool('local',2);
spmd
gpuDevice(labindex+1)
end
reset(gpuDevice(2))
reset(gpuDevice(3))
parfor i=1:100
SingleGPUMatlabCode(i);
end
The code runs for around a second. When I rerun the code after few seconds. I get the message:
Error using parallel.gpu.CUDADevice/reset
An unexpected error occurred during CUDA execution. The
CUDA error was:
unknown error
Error in CreateDictionary
reset(gpuDevice(2))
I tried increasing TdrDelay, but it did not help.
Something in your GPU code is causing an error on the device. Because the code is running asynchronously, this error is not picked up until the next synchronisation point, which is when you run the code again. I would need to see the contents of SingleGPUMatlabCode to know what that error might be. Perhaps there's an allocation failure or an out of bounds access. Errors that aren't correctly handled will get converted to 'unknown error' at the next CUDA operation.
Try adding wait(gpuDevice) inside the loop to identify when the error is occurring.
If either device 2 or 3 are the GTX1080, you may have discovered an issue with MATLAB's restricted support for the Pascal architecture. See https://www.mathworks.com/matlabcentral/answers/309235-can-i-use-my-nvidia-pascal-architecture-gpu-with-matlab-for-gpu-computing
If this is caused by the Windows timeout, you would see a several second screen blackout.

Matlab exception sent by mail is not showing the line of the error

In my matlab script I am sending a mail to me with an exception that tells me, when an error happens, which kind of error it is.
The problem I am facing is the fact that the ME exception is not showing me where the error happens (which line and which part of the code) as matlab usually does. I can't see the error in the matlab terminal too (the program just stops running). The code that sends the mail with the error is below:
try
% my script which can fail....
demo
catch ME
% An error will put here.
errorMessage = sprintf('Error in demo. The error is: %s', ME.message);
%this function just sends the mail
sendmail2me(errorMessage);
What I missed?
The exception ME is an MException object which contains an identifier, the message, a cause and the stack. The identifier is only there to allow MATLAB an unique identification of an error. The message contains a description of the error.
The cause contains an array of MExceptions which have led to the current exception. This allows you to track the exceptions to find the root of your error. As the cause is a (possibly empty) array of MException objects, you could go through the cause in an array and write the information into the mail.
Most important for you is the stack. It is a struct containing three fields: file, name and line. File is the full path to the file/function where the error occurred. Name is (obviously) the name of the file and in line (again obviously) the line where the exception occurred is saved. The stack can also be an array if the error occurred in a function called from you function/script. It would therefore be best to go through stack in a for loop, and concatenate the error message and the contents of the stack.
try
demo;
catch ME
errormsg = sprintf('%s\n',ME.message);
for k=1:length(ME.stack)
errormsg = sprintf('%s\nError in %s (line %d)\n', ...
errormsg,ME.stack(k).name,ME.stack(k).line);
end
sendmail2me(errormsg);
end
You find more detailed information on Exceptions in the MATLAB help pages.

Perl tk main window error

I have a Perl Tk application.
If I move the main window so that it's not right up to the uppermost part of the screen, then the next time the following code is executed, the script fails:
$canvas_fimage_real=$canvas_fimage->Subwidget('canvas');
$canvas_fimage_real=$canvas_fimage unless $canvas_fimage_real;
my $canvas_id=$canvas_fimage_real->id;
my $canvas_fimage_photo=$main_window::main_window->Photo(-format=>'Window', -data=>oct $canvas_id );
And it fails with the following error message:
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 73 (X_GetImage)
Serial number of failed request: 2796
Current serial number in output stream: 2796
The script crashes at the Photo command.
How can I fix this?
Is this a window that is wholly on the screen? The snapshotting facility only works with what is visible on-screen (a low-level X11 condition; not negotiable). As such, you should file a bug report as the snapshot code shouldn't ask for things that it can't get.
Of course, if the window is fully on screen and you're getting that error message anyway, that's a serious problem. File a bug report in that case too!