My outputs are unrealistically high and I have no idea why, d,x,xdot,xdotdot at in magnitudes beyond what it needs to be
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Delta_t=1;
theta=1.4;
a_0=6/(theta*Delta_t)^2;
a_1=3/(theta*Delta_t);
a_2=a_1*2;
a_3=(theta*Delta_t)/2;
a_4=a_0/theta;
a_5=-a_2/theta;
a_6=1-3/theta;
a_7=Delta_t/2;
a_8=(Delta_t^2)/6;
%Stiffness Matrix
M=22; %lb/ft
K=0.8; %Stiffness Coeff.
C=0.25674; %Damping Coeff.
K_hat=a_0*M+a_1*C+K
%Payload
L=100;
t=1:300;
Mw = zeros(numel(t),1);
Mw(t<80) = 20;
Mw(t>=80 & t<=90) = 35;
Mw(t>90 & t<=100) = 60;
Mw(t>100 & t<=200)= 100;
Mw(t>200) = 20;
Fv=0.04*L*Mw; %Variable of the Load
F=Fv.';
x=3; %ft
x_dot=3; %ft/s
x_dotdot=3; %ft/s^2
for ii=1:220
F_hat(ii+1)=F(ii)+theta*(F(ii+1)-F(ii))+M*(a_0*x(ii)+a_2*x_dot(ii)+2*x_dotdot(ii))+C*(a_1*x(ii)+2*x_dot(ii)+a_3*x_dotdot(ii));
d(:,ii+1)=F_hat(:,ii)/K_hat; % x=F/K
x_dotdot(:,ii+1)=a_4*(d(:,ii+1)-x(:,ii))+a_5*x_dot(:,ii)+a_6*x_dotdot(:,ii);
x_dot(:,ii+1)=x_dot(:,ii)+a_7*(x_dotdot(:,ii+1)+x_dotdot(:,ii));
x(:,ii+1)=x(:,ii)+Delta_t*x_dot(:,ii)+a_8*(x_dotdot(:,ii+1)+2*x_dotdot(:,ii));
end
plot(x_dot)
6 comentarios
the cyclist
el 12 de Mzo. de 2022
(Edited question so that the 220 iterations worth of output are not displayed.)
Respuestas (1)
Walter Roberson
el 12 de Mzo. de 2022
Your outputs wobble a lot; they just look straight because the wobbles increase enough as you go that the previous part is straight by comparison .
Switching to symbolic shows that the problem is not with round-off error in the calculations: there is something in the formulas that leads to this state.
Q = @(v) sym(v);
Delta_t = Q(1);
theta = Q(1.4);
a_0=6/(theta*Delta_t)^2;
a_1=3/(theta*Delta_t);
a_2=a_1*2;
a_3=(theta*Delta_t)/2;
a_4=a_0/theta;
a_5=-a_2/theta;
a_6=1-3/theta;
a_7=Delta_t/2;
a_8=(Delta_t^2)/6;
%Stiffness Matrix
M = Q(22); %lb/ft
K = Q(0.8); %Stiffness Coeff.
C = Q(0.25674); %Damping Coeff.
K_hat=a_0*M+a_1*C+K
%Payload
L = Q(100);
t = Q(1:300);
Mw = zeros(numel(t),1,'sym');
Mw(t<80) = 20;
Mw(t>=80 & t<=90) = 35;
Mw(t>90 & t<=100) = 60;
Mw(t>100 & t<=200)= 100;
Mw(t>200) = 20;
Fv = Q(0.04)*L*Mw; %Variable of the Load
F=Fv.';
x = Q(3); %ft
x_dot = Q(3); %ft/s
x_dotdot = Q(3); %ft/s^2
for ii=1:220
F_hat(ii+1) = F(ii)+theta*(F(ii+1)-F(ii))+M*(a_0*x(ii)+a_2*x_dot(ii)+2*x_dotdot(ii))+C*(a_1*x(ii)+2*x_dot(ii)+a_3*x_dotdot(ii));
d(ii+1) = F_hat(ii)/K_hat; % x=F/K
x_dotdot(ii+1) = a_4*(d(ii+1)-x(ii))+a_5*x_dot(ii)+a_6*x_dotdot(ii);
x_dot(ii+1) = x_dot(ii)+a_7*(x_dotdot(ii+1)+x_dotdot(ii));
x(ii+1) = x(ii)+Delta_t*x_dot(ii)+a_8*(x_dotdot(ii+1)+2*x_dotdot(ii));
end
plot(double(x_dot))
x_dot(end)
vpa(ans)
plot(double(x_dot(1:150)))
plot(double(x_dot(1:50)))
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





