Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



code operating speed is very slow
Posted:
May 13, 2010 4:05 AM


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?



