# How can we use a Heaviside function for differential equation having moving load ?

3 visualizaciones (últimos 30 días)
Rajni kant kumar el 10 de Abr. de 2021
Respondida: Vaibhav el 29 de Mayo de 2024
I have a differential equation mentioned in function file where i have to apply moving load. I want to verify the approach that i have tried to get a moving load using heaviside function. so please help me implimenting correctly the moving load.
clc
clear all
%%
% time span
tspan=[0:0.1:10];
y0=[0;0];
%% moving load
F0=9.8; % magnitude of moving load
L=4; % length
V=0.1; % velocity
m=28.152;
C=500;
[t,y]=ode45(@(t,y) Lin(t,y,C,w,F0,m,L,V),tspan,y0);
function [f]=Linear12(t,y,C,F0,m,L,V)
%% moving load
p1= F0*sqrt(2/m*L)*sin((pi*V*t)/L).*heaviside(L/V-t);
%%
f= zeros(2,1);
%% for beam with linear absorber
f(1)=y(2);
f(2)= -50^2*y(1)-C*y(2)+p1;
end
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Vaibhav el 29 de Mayo de 2024
Hi Rajni
I understand that you would like to implement the moving load using the Heaviside function in your differential equation.
Ensure the function name inside the ode45 call matches the actual function definition. In your original code, you called Lin inside ode45, but your function was defined as Linear12. I have corrected this to use Linear12 in both places. Your usage of the Heaviside function to model the moving load in in the correct direction. The expression heaviside(L/V - t) effectively turns on the force as the load starts affecting the system, based on the velocity of the load and the length of the system it's moving over.
Here it the code for your reference:
clc;
clear all;
% Time span
tspan = [0:0.1:10];
y0 = [0; 0];
% Parameters
F0 = 9.8; % Magnitude of moving load
L = 4; % Length
V = 0.1; % Velocity
m = 28.152;
C = 500;
% Solve the ODE
[t,y] = ode45(@(t,y) Linear12(t,y,C,F0,m,L,V), tspan, y0);
% Plot the solution
plot(t, y(:,1));
xlabel('Time');
ylabel('Displacement');
title('Displacement over Time');
function [f] = Linear12(t,y,C,F0,m,L,V)
% Moving load
p1 = F0 * sqrt(2/(m*L)) * sin((pi*V*t)/L) .* heaviside(L/V - t);
% Initialize the derivative vector
f = zeros(2,1);
% Differential equations for the system
f(1) = y(2);
f(2) = -50^2 * y(1) - C * y(2) + p1;
end
Hope it helps!
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Linear Least Squares 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!

Translated by