"Wenxu Li" <lwxlee@gmail.com> wrote in message <hsgbs1$nvf$1@fred.mathworks.com>...
> I try to simulate a one DoF massspring system,the code is as follows:
> %M02, solution
> tspan=0:0.06:10*pi;
> x0=[0;5.0];
> [t,x]=ode23w('friction_force',tspan,x0);
> plot(t,x(:,1));
>
> %function
> function y=friction_force(t,x)
> m=1;
> k=1;
> Frictionforce=10;
> y=zeros(2,1);
> y(1)=x(2);
> y(2)=Frictionforce*sign(x(2))/mk/m*x(1);
>
> My question is when I use y(2)=Frictionforce*sign(x(2))/mk/m*x(1), i.e. without minus
> before Frictionforce, the code operates very quickly, while I add a minus, it is very slow, more than half an hour to get the results. Can anybody tell what is the matter?
The dynamics of the system will be entirely different with and without that minus sign. With the minus sign present, representing an actual retarding friction force, the mass can get stuck in a situation where the velocity is zero and the frictional force alternates back and forth rapidly. Such a discontinuity would slow down the functioning of the algorithm greatly since it is designed to handle continuous functions.
Without the minus sign the oscillations back and forth take on wider and wider swings so that there is no stuckatzerovelocity situation occurring. Hence the discontinuity has far less effect on the speed of the algorithm. However, it is not a realistic way for friction to behave.
Roger Stafford
