Spring mass system subjected to impulse excitation
조회 수: 4 (최근 30일)
이전 댓글 표시
function [f] = impulse(t,x,h,i)
mu=0.2; wn = 17.1552;
tspan = 0:0.01:1.35;
h = [1 zeros(1,135)];
for i = 1 : length(tspan)
% h(i) = 0 ;
% h(1) = 1 ;
% % hh(i)= 0 + h(i);
% The output is 1 only if the input is 0
% if tspan == 0
% h(i) = 0;
% end
f=zeros(2,1);
f(2) = x(2);
f(1)= -mu*9.81*sign(x(2)) - (wn^2)*x(1) + h(i) ;
end
end
the main problem is the value h(i) is not subtituting in 'f' equation.
The Script file for the above function file is -----
clear all
clc;
clf;
tic;
mu = 0.2;
wn = 17.1552;
tspan=0:0.01:1.35;
x0=[0;0];
[t,x]=ode45(@impulse,tspan,x0);
y = x(:,1);
ydot = x(:,2);
figure(1);
plot(t,y,'r','linewidth',2);
can some one please help me with code for the above equation of motion. I tried a lot but I coudn't finished. I am not good in matlab but this is needed very much. Around 15 days back I posted my code also but I coudn't follow the comments made by few people. Please help me.
댓글 수: 5
darova
2020년 2월 13일
Please explain what is h(i) ()
DOn't you forgot to divide the entire expression by m?
f(1)= -mu*9.81*sign(x(2)) - (wn^2)*x(1) + h(i) ;
답변 (1개)
Bjorn Gustavsson
2020년 2월 25일
You seem to have misunderstood how matlab integrates ODEs.
Your ODE-function, impulse, should return the derivatives, and , at time t. You put an unnecessary loop in there where you spend plenty of time doing mostly nothing. This is an example of an ODE for a falling body in with some drag:
function dxdtdvxdt = ode_falldrag(t,xv,C)
dxdtdvxdt(1) = xv(2); % dxdt = v, second component of vx
dxdtdvxdt(2) = -9.81 - C*vx(2)*abs(vx(2));
end
Then you can call it something like:
[t,x]=ode45(@(t,x) ode_falldrag(t,x,1.23),tspan,x0);
where I've arbitrarily chosen a random drag-coefficient.
As for how to model impulse, you have to do more of the work. I suggest that you take a look at approximating the Dirac-pulses with Gaussians with decreasing width.
HTH
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 General Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!