Can anyone help me understand following code consisting of multiple inputs in Simulink to get a response with impulse & without impulse , & comparing it with analytical

2 次查看(过去 30 天)
%%
clear all
close all
clc
m=1200;k=400000;zta=0.4;
c=2*zta*sqrt(m*k);wn=sqrt(k/m);
wd=sqrt(1-zta^2)*wn;
td=0.072;
As = [0 1;-k/m -c/m];
Bs = [0 1]';
Cs1 = [k/m c/m];
Cs2 = [1 0];
Ds = 0;
Asj = [0 1;-k/m -c/m];
Bsj = [0 0;k/m c/m];
Csj = [1 0];
Dsj = [-1 0];
fs=10000;%sampling frequency
sim('speedbump1.mdl');
plot(time,output(:,[1 2]));
%% Analytic data
% plugg in
syms tau t
dt=0.001;
%w1 0<t<td
time1=0:0.001:0.072;
w11=1/(wd)*int(190.36*sin(pi/td*tau)*(exp(-zta*wn*(t-tau)).*sin(wd*(ttau))),tau,0,t);
w11=double(subs(w11,t,time1));%without impulse
t=time1;h1=0.26*(exp(-zta*wn*t).*sin(wd*t));%first impulse
w12=w11-h1;%without impulse
%w2
syms t
time2=0.072:0.01:10;
w21=1/(wd)*int(190.36*sin(pi/td*tau)*(exp(-zta*wn*(t-tau)).*sin(wd*(ttau))),tau,0,td);
w21=double(subs(w21,t,time2));%without impulse
t=time2;
h1=0.26*(exp(-zta*wn*t).*sin(wd*t));%first impulse
h2=0.26*(exp(-zta*wn*(t-0.072)).*sin(wd*(t-0.072)));
w22=w21-h1-h2;%with impuse%%
save analyticdata
%%
load analyticdata;%load analytic data
figure
plot(time,output(:,2),'linewidth',2);hold on
plot(time1,real(w12),'r.','linewidth',2);
plot(time2,real(w22),'r.','linewidth',2);
title('Response with Delta Function')
xlabel('Time (sec)','fontname','times','fontsize',14);
ylabel('Displacement (m)','fontname','times','fontsize',14)
title('Numerical response overlayed with analytic solution with impulse impulses','fontname','times','fontsize',14)
legend('Simulink','Analytic');
xlim([0 1]);
figure
plot(time,output(:,1),'linewidth',2);hold on
plot(time1,real(w11),'r-.','linewidth',2);
plot(time2,real(w21),'r-.','linewidth',2);
xlabel('Time (sec)','fontname','times','fontsize',14);
ylabel('Displacement (m)','fontname','times','fontsize',14)
title('Numerical response overlayed with analytic solution without impulses','fontname','times','fontsize',14)
legend('Simulink','Analytic');
xlim([0 1]);
%%
figure
plot(time,in(:,1),'-.','linewidth',2)
hold on
plot(time,in(:,2),'r')
xlabel('Time (sec)','fontname','times','fontsize',14);
ylabel('Acceleration (m/s^2)','fontname','times','fontsize',14)
xlim([0 0.08])
legend('Without Impulse','With Impulse');

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Statistics and Linear Algebra 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by