ode 45 , odeset, nonnegative

조회 수: 5 (최근 30일)
jorge reula
jorge reula 2019년 5월 17일
편집: jorge reula 2019년 5월 18일
I am working with ODE 45, in the simulation of a vehicle's damping system. I want to limit the displacement of the wheels, since they would sink in the earth, however the program eliminates many positive peaks for no reason. How could I avoid this error?
  댓글 수: 2
Jan
Jan 2019년 5월 17일
"the program eliminates many positive peaks for no reason" - this is not clear enough yet. Please post the code and explain, what "positive peaks" are. Of course the code does not do anything "for no reason". But why it is doing what can be explained only, if you share the code.
jorge reula
jorge reula 2019년 5월 18일
편집: jorge reula 2019년 5월 18일
if true
% code
endwhen the nonnegative command is entered, in equations 1 and 5, center of mass and pitch respectively,
% cut the curve appropriately, but when I cut the answer of equations 3 and 7 cut positive parts
% that should not.
%%%%SCRIPT
% %ARGO 1.3
clc
clear all
%Vehicle information
mb=1114/2; %MASA MEDIO VC
I=97.89; %MOM IN [kg/m^2]
kb=16000; %COEF EL AMORT
b=1500; %COEF AMORT
mwi=75; %MASA RUEDA
kwi=160000; %COEF EL RDA
kbt=kb;
bt=b;
Lt=2.521; %LONG TOT
ld=0.7;
lt=-(Lt-ld);
h=0.1;
e=0.5; %ANCHO LOMO [m]
v=100/36; %VEL VC [m/s]
t=[0 4];
CI=[0 0 0 0 0 0 0 0]; %COND INICIAL Zb(1) Zbp(2) Zw1(3) Zwp1(4) tita(5) titap(6) Zw2(7) Zwp2(8)
opts = odeset('AbsTol',1e-6,'Reltol',1e-4,'nonNegative',[3 7],'MaxStep',0.1,'refine',4);
[T,y]=ode45(@solu,t,CI,opts,mwi,mb,b,kb,kwi,I,v,e,Lt,lt,ld,bt,kbt,h); % %CENTRO DE MASA % figure (1) subplot(2,1,1) plot(T,y(:,1)) title('CM') grid legend('P') % % %PITCH subplot(2,1,2) plot(T,y(:,5)) title('PITCH') grid legend('P') %wheel figure (2) plot(T,y(:,3),T,y(:,7)) title('RUEDA del') grid legend('PR1')%,'PR2') %%%% ODE45Ffunction function[y]=solu(t,CI,mwi,mb,b,kb,kwi,I,v,e,Lt,lt,ld,bt,kbt,h) ue=h*cos((2*pi*v/e)*(t-0.5)); %wave if (0.5<=t && t<0.5+(e/v)) u=ue; u1=0; elseif 0.5+(e/v)+(ld-lt)/(v)<=t && t<0.5+(e/v)+(ld-lt)/(v)+(e/v) u=0; u1=ue; else u=0; u1=0; end % CENTRO DE MASA y(1,1)=CI(2); y(2,1)=(-b*(CI(2)+ld*CI(6)-CI(4))-bt*(CI(2)+lt*CI(6)-CI(8)))/(mb) + (-kb*(CI(1)+ld*CI(5)-CI(3))-kbt*(CI(1)+lt*CI(5)-CI(7)))/(mb); % RUEDA 1 y(3,1)=CI(4); y(4,1)=(b*(CI(2)+ld*CI(6)-CI(4))+kb*(CI(1)+ld*CI(5)-CI(3))-kwi*(CI(3)-u))/(mwi); % RUEDA 2 y(7,1)=CI(8); y(8,1)=(bt*(CI(2)+lt*CI(6)-CI(8))+kbt*(CI(1)+lt*CI(5)-CI(7))-kwi*(CI(7)-u1))/(mwi); % PITCH y(5,1)=CI(6); y(6,1)=((-b*(CI(2)+ld*CI(6)-CI(4))*ld-kb*(CI(1)+ld*CI(5)-CI(3))*ld)/I + (-bt*(CI(2)+lt*CI(6)-CI(8))*lt-kbt*(CI(1)+lt*CI(5)-CI(7))*lt)/I);

댓글을 달려면 로그인하십시오.

답변 (1개)

jorge reula
jorge reula 2019년 5월 17일
%when the nonnegative command is entered, in equations 1 and 5, center of mass and pitch respectively,
% cut the curve appropriately, but when I cut the answer of equations 3 and 7 cut positive parts
% that should not.
%%%% SCRIPT
% %ARGO 1.3
clc
clear all
%Vehicle information
mb=1114/2; %MASA MEDIO VC
I=97.89; %MOM IN [kg/m^2]
kb=16000; %COEF EL AMORT
b=1500; %COEF AMORT
mwi=75; %MASA RUEDA
kwi=160000; %COEF EL RDA
kbt=kb;
bt=b;
Lt=2.521; %LONG TOT
ld=0.7;
lt=-(Lt-ld);
h=0.1;
e=0.5; %ANCHO LOMO [m]
v=100/36; %VEL VC [m/s]
t=[0 4];
CI=[0 0 0 0 0 0 0 0]; %COND INICIAL Zb(1) Zbp(2) Zw1(3) Zwp1(4) tita(5) titap(6) Zw2(7) Zwp2(8)
opts = odeset('AbsTol',1e-6,'Reltol',1e-4,'nonNegative',[3 7],'MaxStep',0.1,'refine',4);
[T,y]=ode45(@solu,t,CI,opts,mwi,mb,b,kb,kwi,I,v,e,Lt,lt,ld,bt,kbt,h);
% %CENTRO DE MASA
%
figure (1)
subplot(2,1,1)
plot(T,y(:,1))
title('CM')
grid
legend('P')
%
% %PITCH
subplot(2,1,2)
plot(T,y(:,5))
title('PITCH')
grid
legend('P')
%wheel
figure (2)
plot(T,y(:,3),T,y(:,7))
title('RUEDA del')
grid
legend('PR1')%,'PR2')
%%%% ODE45Ffunction
function[y]=solu(t,CI,mwi,mb,b,kb,kwi,I,v,e,Lt,lt,ld,bt,kbt,h)
ue=h*cos((2*pi*v/e)*(t-0.5)); %wave
if (0.5<=t && t<0.5+(e/v))
u=ue;
u1=0;
elseif 0.5+(e/v)+(ld-lt)/(v)<=t && t<0.5+(e/v)+(ld-lt)/(v)+(e/v)
u=0;
u1=ue;
else
u=0;
u1=0;
end
% CENTRO DE MASA
y(1,1)=CI(2);
y(2,1)=(-b*(CI(2)+ld*CI(6)-CI(4))-bt*(CI(2)+lt*CI(6)-CI(8)))/(mb) + (-kb*(CI(1)+ld*CI(5)-CI(3))-kbt*(CI(1)+lt*CI(5)-CI(7)))/(mb);
% RUEDA 1
y(3,1)=CI(4);
y(4,1)=(b*(CI(2)+ld*CI(6)-CI(4))+kb*(CI(1)+ld*CI(5)-CI(3))-kwi*(CI(3)-u))/(mwi);
% RUEDA 2
y(7,1)=CI(8);
y(8,1)=(bt*(CI(2)+lt*CI(6)-CI(8))+kbt*(CI(1)+lt*CI(5)-CI(7))-kwi*(CI(7)-u1))/(mwi);
% PITCH
y(5,1)=CI(6);
y(6,1)=((-b*(CI(2)+ld*CI(6)-CI(4))*ld-kb*(CI(1)+ld*CI(5)-CI(3))*ld)/I + (-bt*(CI(2)+lt*CI(6)-CI(8))*lt-kbt*(CI(1)+lt*CI(5)-CI(7))*lt)/I);

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by