Erasemode error: How do i correct it?

39 views (last 30 days)
KLETECH MOTORSPORTS
KLETECH MOTORSPORTS on 13 Nov 2020
Answered: Maadhav Akula on 17 Nov 2020
Tried running this code i found in Rudrapratap for the animation of a 2D bar pendulum. I'm getting the following errors:
Warning: The EraseMode property is no longer supported and will error in a future release.
> In pendmotion22 (line 20)
Warning: The EraseMode property is no longer supported and will error in a future release.
> In pendmotion22 (line 24)
Warning: The EraseMode property is no longer supported and will error in a future release.
> In pendmotion22 (line 29)
Warning: The EraseMode property is no longer supported and will error in a future release.
> In pendmotion22 (line 40)
Warning: The EraseMode property is no longer supported and will error in a future release.
> In pendmotion22 (line 43)
Any idea what i can change in the code?
% get basic data for animat ion
% ask the user for initi al position
disp(' Please specify the init ial angle from the')
disp(' verti cal upright position . ')
disp(' ')
offset=input ( 'Enter the initial angle now : ');
tfinal=input ( ' Please enter the duration of simulation: ' ) ; % ask the user f or t ime of s imulation
disp ( ' I am working .... ' )
theta = pi-offset ; % initial angle
thetadot = 0; % initial angular speed
dt =.2; t=0 ; tf=tfinal ; % time step , initial and final time
disp ( ' Watch the graphics screen ' )
clf % clear figure and stuff
hl = axes('position',[0.55 .1 .4 .3]);
axis( [0 tf -4 4] ); % set axis limits
xlabel( 'time') , ylabel('displacement ')
Displ = line('xdata' , [] , 'ydata' , [] , 'marker','.' , 'erasemode' , 'none' );
h2 = axes( 'position' , [0.55 .55 .4 .3]);
axis ( [0 tf -4 4] ) ; % set axis limits
xlabel ( ' t ime') , ylabel ('velocity ')
Vel = line ( 'xdata' , [] , 'ydata' , [] , 'marker' , '.' , 'erasemode' , 'none' ) ;
h3 = axes( 'position',[.1 .1 .4 .4]);
axis ( [-pi pi -4 4] ) % set axis limits
axis ('square')
xlabel ( 'displacement' ) , ylabel ( 'velocity')
Phase = line('xdata' , [] , 'ydata' , [] , 'marker' , '.' , 'erasemode' , 'none' ) ;
h4 = axes ( 'position' , [.1 .55 .4 .4]);
axis ( [-2 2 -2 2] ) % set axis limits
axis ( 'square' )
data = [0 0; - 1.8 0] ;
phi = 0;
% coordinates of endpoints of the bar
% initial orientat ion
R = [cos(phi) -sin(phi ) ; +sin(phi ) cos(phi)] ; % rotation matrix
data=R*data;
%-----def ine the obj ects called bar , hinge , and path .
bar = line('xdata' , data (1, :), 'ydata' , data (2, :),...
'linewidth' ,3, 'erase' , 'xor') ;
hinge = line( 'xdata' , 0 , 'ydata' , 0 , 'marker' , 'o' , 'markersize' , [10] ) ;
path = line( 'xdata' , [] , 'ydata' , [] , 'marker' , '.' , 'erasemode' , 'none' ) ;
%------Euler 's method for numeri cal integrat ion
while (t<tfinal )
end
t = t+dt ;
theta = theta + thetadot*dt ;
thetadot = thetadot -sin(theta) *dt ;
R = [cos(theta) ( -sin(theta) ); sin(theta) cos(theta) ];
datanew = R*data;
%---- change the property values of the obj ects : path and bar .
set (path , ' xdata ', datanew( 1,1 ), 'ydata ', datanew( 2 , 1 ) ) ;
set (bar , 'xdata' , datanew (1, :), 'ydata' , datanew (2, :) );
set (Phase , 'xdata ', theta, 'ydata ', thetadot );
set (Displ , 'xdata', t, 'ydata' , theta ) ;
set (Vel , 'xdata' , t, 'ydata' , thetadot ) ;
drawnow ;

Answers (1)

Maadhav Akula
Maadhav Akula on 17 Nov 2020
Erasemode property has been removed starting from R2014b, you can refer the following answer for how to replace that property:

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!