- The time-stepping loop is not implemented.
- The values inside 't' are non-integer, this can't be used as indices for an array.
- Variables 'x_0', 'x_dot(t)', and 'x_dotdot(t)' are not properly defined for the initial state and within the loop.
- The 'F_hat' calculation uses 'F(t)' and 'F(t+1)', which is not valid MATLAB syntax and does not account for the end of the array.
- The update equations for 'x(t+1)', 'x_dot(t+1)', and 'x_dotdot(t+1)' are outside of a loop and do not accumulate the results over time.
Trying to make Dynamic equations work with varying mass over time
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to make the dynamic equations at the bottom to create plots that show the change to displacement, velocity, and acceleration from change of mass applied to the conveyor belt.
Delta_t=0.2;
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;
%Initial Input
x=1; %ft
x_dot=3; %ft/s
x_dotdot=0.1; %ft/s^2
%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:0.2:300;
Mw = zeros(numel(t),1);
Mw(t<100) = 20;
Mw(t>=100 & t<=200)=100;
Mw(t>200) = 17;
F=0.04*L*Mw %Variable of the Load
F_hat=F(t)+theta*(F(t+1)-F(t))+M*(a_0*x_0+a_2*x_dot(t)+2*x_dotdot(t))+C*(a_1*x_0+2*x_dot(t)+a_3*x_dotdot(t))
x(t+1)=F_hat/K_hat % x=F/K
x_dotdot(t+1)=a_4*(x(t+1)-x(t))+a_5*x_dot(t)+a_6*x_dotdot(t)
x_dot(t+1)=x_dot(t)+a_7*(x_dotdot(t+1)+x_dotdot(t))
x(t+1)=x(t)+Delta_t*x_dot(t)+a_8*(x_dotdot(t+1)+2*x_dotdot(t))
0 commentaires
Réponses (1)
Yash
le 9 Fév 2024
Hi Mark,
It looks like you're trying to implement a numerical simulation of a dynamic system using a variation of the Newmark-beta method. However, there are a few issues in the code you've provided:
Given below is a correct MATLAB code for your implementation:
Delta_t = 0.2;
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;
% Initial conditions
x = 1; % ft
x_dot = 3; % ft/s
x_dotdot = 0.1; % ft/s^2
% 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 = 0:Delta_t:300;
Mw = zeros(numel(t),1);
Mw(t<100) = 20;
Mw(t>=100 & t<=200) = 100;
Mw(t>200) = 17;
F = 0.04*L*Mw; % Variable of the Load
% Preallocate arrays for results
x_result = zeros(numel(t),1);
x_dot_result = zeros(numel(t),1);
x_dotdot_result = zeros(numel(t),1);
% Set initial conditions
x_result(1) = x;
x_dot_result(1) = x_dot;
x_dotdot_result(1) = x_dotdot;
% Time-stepping loop
for i = 1:numel(t)-1
F_current = F(i);
F_next = F(i+1);
F_hat = F_current + theta*(F_next - F_current) + M*(a_0*x + a_2*x_dot + 2*x_dotdot) + C*(a_1*x + 2*x_dot + a_3*x_dotdot);
x_next = F_hat / K_hat;
x_dotdot_next = a_4*(x_next - x) + a_5*x_dot + a_6*x_dotdot;
x_dot_next = x_dot + a_7*(x_dotdot_next + x_dotdot);
x = x + Delta_t*x_dot + a_8*(x_dotdot_next + 2*x_dotdot);
x_result(i+1) = x;
x_dot_result(i+1) = x_dot_next;
x_dotdot_result(i+1) = x_dotdot_next;
x_dot = x_dot_next;
x_dotdot = x_dotdot_next;
end
% Plot the results
subplot(3, 1, 1);
plot(t, x_result);
title('Displacement over Time');
xlabel('Time (s)');
ylabel('Displacement (ft)');
subplot(3, 1, 2);
plot(t, x_dot_result);
title('Velocity over Time');
xlabel('Time (s)');
ylabel('Velocity (ft/s)');
subplot(3, 1, 3);
plot(t, x_dotdot_result);
title('Acceleration over Time');
xlabel('Time (s)');
ylabel('Acceleration (ft/s^2)');
This MATLAB script should calculate the displacement 'x_result', velocity 'x_dot_result', and acceleration 'x_dotdot_result' of the system over time and plot the results. Make sure to adjust the script if there are any additional requirements or initial conditions that have not been specified here.
Hope this helps!
0 commentaires
Voir également
Catégories
En savoir plus sur Guidance, Navigation, and Control (GNC) dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!