Plot disappears after I move it or I rotate it
Show older comments
I'm executing a very simple script the implements the Hill eqations and outputs a 3D graph.
When I move the plot that the script creates or I try to rotate the 3D image, Matlab behaves as if I had press enter in the command window: it creates a new line in the command window, puts in the front the main Matlab application (with the command window), and subsequently the plot gets hidden in the back.
Intrestingly this happens only if I release the mouse where the plot windows is positioned initially. E.g. if I start to pinch the plot window on the top part pressing the left mouse button, I move it quite a bit more up, and than I release the left mouse button, the problem dosn't arise.
I will add here how my desktop looks before and after the plot is moved.

I have this problem in both Matlab 2023a & Matlab 2022b.
In the 2022b version sometimes I also get the following messages:
Operation terminated by user during matlab.graphics.controls.ToolbarController/handleMouseMotion &
Operation terminated by user.
I would be really happy if anybody could help me with this. Thank you in advance.
Here is the script that I'm running
% Clohessy-Wiltshire Equations
clearvars; close all; clc;
% Define constants
R_e = 6378.1;
a = R_e + 400;
mu = 398600.4418; % Standard gravitational parameter of Earth (km^3/s^2)
n = sqrt(mu/(a^3)); % Mean motion (rad/s)
% Define initial conditions
x0 = 0; % Initial relative position along x-axis (km)
y0 = 0; % Initial relative position along y-axis (km)
z0 = 0; % Initial relative position along z-axis (km)
xdot0 = 0.001; % Initial relative velocity along x-axis (km/s)
ydot0 = 0; % Initial relative velocity along y-axis (km/s)
zdot0 = 0; % Initial relative velocity along z-axis (km/s)
% Define time span and step size
tspan = [0 1000]; % Time span (s)
dt = 1; % Step size (s)
% Initialize arrays to store results
t = tspan(1):dt:tspan(2); % Time array
numSteps = numel(t);
x = zeros(numSteps, 1);
y = zeros(numSteps, 1);
z = zeros(numSteps, 1);
xdot = zeros(numSteps, 1);
ydot = zeros(numSteps, 1);
zdot = zeros(numSteps, 1);
% Set initial conditions
x(1) = x0;
y(1) = y0;
z(1) = z0;
xdot(1) = xdot0;
ydot(1) = ydot0;
zdot(1) = zdot0;
% Numerically integrate the Clohessy-Wiltshire equations using Euler's method
for i = 2:numSteps
xddot = 3*n^2*x(i-1) + 2*n*ydot(i-1);
yddot = -2*n*y(i-1) + n^2*x(i-1);
zddot = -n^2*z(i-1);
xdot(i) = xdot(i-1) + xddot*dt;
ydot(i) = ydot(i-1) + yddot*dt;
zdot(i) = zdot(i-1) + zddot*dt;
x(i) = x(i-1) + xdot(i)*dt;
y(i) = y(i-1) + ydot(i)*dt;
z(i) = z(i-1) + zdot(i)*dt;
end
% Plot the relative motion
figure;
plot3(x, y, z);
xlabel('X (km)');
ylabel('Y (km)');
zlabel('Z (km)');
grid on;
title('Relative Motion (Clohessy-Wiltshire Equations)');
3 Comments
Walter Roberson
on 23 May 2023
Could you show us the output of
get(groot, 'Default')
MARIO PASTORE
on 24 May 2023
Walter Roberson
on 24 May 2023
I was hoping that there might happen to be a default Callback of some kind that might be interfering.
At the moment I am running short of ideas on how the problem could be happening for you.
Hmmm... experiment with
restoredefaultpath; rehash toolboxcache
if the problem clears up then you have some third-party function with the same name as MATLAB functions that are interfering.
If the problem does not clear up... ummm, maybe check to see whether you have the latest graphics drivers for your graphics card.
Answers (0)
Categories
Find more on 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!