diff --git a/Animation.m b/Animation.m new file mode 100644 index 0000000..1a8ad1a --- /dev/null +++ b/Animation.m @@ -0,0 +1,54 @@ +function Animation(x,t) + +fs=20; lw=4; ms = 30; +fst = 0.8*fs; +x0screen=50;y0screen=200;WidthScreen=1300;HeightScreen=300; +Blue = [0 0.4470 0.7410]; +Orange = [0.8500 0.3250 0.0980]; +Yellow = [0.9290 0.6940 0.1250]; +Violet = [0.4940 0.1840 0.5560]; +Green = [0.4660 0.6740 0.1880]; +Cyan = [0.3010 0.7450 0.9330]; +quality = '-r210'; + + +a = 0; +b = 1; +Cw1 = @(zeta) (zeta^2*(2*zeta^3 - 5*zeta^2 + 10))/20; +Cw2 = @(zeta) -(zeta^4*(2*zeta - 5))/20; +Cw3 = @(zeta) (zeta^3*(3*zeta^2 - 10*zeta + 10))/60; +Cw4 = @(zeta) (zeta^4*(3*zeta - 5))/60; + + +zeta_d = linspace(a,b); +w = zeros(8,length(t)); +for i = 1:length(t) + for j = 1:length(zeta_d) + Cw = [Cw1(zeta_d(j)),Cw2(zeta_d(j)),Cw3(zeta_d(j)),Cw4(zeta_d(j)),0,0,0,0]; + w(j,i) = Cw*x(:,i); + end +end + +figure +set(gcf,'units','points','position',[x0screen,y0screen,WidthScreen,HeightScreen]) +hold on +% pu = plot(zeta_d,u(:,1),'LineWidth',lw); +% pv = plot(zeta_d,v(:,1),'LineWidth',lw); +pw = plot(zeta_d,w(:,1),'LineWidth',lw*4); +legend({'$w(\zeta,t)$'},'Interpreter','latex','FontSize',fs,'Location','Northwest') +xlabel({'space $\zeta$'},'Interpreter','latex','FontSize',fs) +set(gca,'FontSize',fst) +ylim([-0.7,0.7]) +xlim([a,b]) +% pause + +for i = 1:10:length(t) + + % set(pu,'YData',u(:,i)) + % set(pv,'YData',v(:,i)) + set(pw,'YData',w(:,i)) + pause(0.0001) +end + + +end \ No newline at end of file diff --git a/BE-Beam.pdf b/BE-Beam.pdf new file mode 100644 index 0000000..d881c63 Binary files /dev/null and b/BE-Beam.pdf differ diff --git a/BE_Beam.m b/BE_Beam.m new file mode 100644 index 0000000..454c889 --- /dev/null +++ b/BE_Beam.m @@ -0,0 +1,116 @@ +%% [BE] Digital control of cantilever beam +% Justin Bos +% +% Wissal Guarni +% +% Nolan Reynier Nomer +% +% Aleksander Taban + +E = [13/35 9/70 11/210 -13/420 ; + 9/70 13/35 13/420 -11/210 ; + 11/210 13/420 1/105 -1/140 ; + -13/420 -11/210 -1/140 1/105] ; +D = [-6/5 6/5 -1/10 -1/10 ; + 6/5 -6/5 1/10 11/10 ; + -11/10 1/10 -2/15 1/30 ; + -1/10 1/10 1/30 -2/15] ; + +phi = @(zeta) [2*zeta^3-3*zeta^2+1 ; + 3*zeta^2-2*zeta^3 ; + zeta^3-2*zeta^2+zeta ; + zeta^3-zeta^2 ] ; +L=1; +%% +A = [zeros(4), inv(E)*D ; + -inv(E)*(D'), zeros(4) ] ; +phi_L = phi(L) ; +B = [zeros(4,1) ; -inv(E)*phi_L] ; +C = [zeros(1,4) , -phi_L'] ; +%% +Ts1 = 0.01 ; +Ts2 = 0.02 ; +Ts3 = 0.04 ; + +eig_cont = eig(A); +sys = ss(A, B, C, 0) ; +figure; +subplot(1,3,1) ; +plot(eig_cont, 'x'); +hold off; + +subplot(1,3,2); +eig_tustin1 = eig(c2d(sys, Ts1, 'tustin')) ; +eig_tustin2 = eig(c2d(sys, Ts2, 'tustin')) ; +eig_tustin3 = eig(c2d(sys, Ts3, 'tustin')) ; +plot(eig_tustin1,'x'); +hold on; +plot(eig_tustin2,'x'); +plot(eig_tustin3,'x'); +hold off; + +subplot(1,3,3); +eig_zoh1 = eig(c2d(sys, Ts1, 'zoh')) ; +sys_zoh1 = c2d(sys, Ts1, 'zoh'); +eig_zoh2 = eig(c2d(sys, Ts2, 'zoh')) ; +eig_zoh3 = eig(c2d(sys, Ts3, 'zoh')) ; +plot(eig_zoh1,'x'); +hold on; +pzmap(sys_zoh1); +plot(eig_zoh3,'x'); +hold off; +%% +% Conlsuion : On en conclut qqc. + +figure; +t = 0:0.01:10; +u = double (t >= 1) ; +lsim(sys,u, t); +title(); +legend(); +xlabel(); +ylabel(); +%% +% + +Cw = @(zeta) [zeta^2*(2*zeta^3-5*zeta^2+10)/20 ... + -zeta^4*(2*zeta-5)/20 ... + zeta^3*(3*zeta^2-10*zeta+10)/60 ... + zeta^4*(3*zeta-5)/60 ... + 0, 0, 0, 0]; +Cw_L = Cw(L); + +TransientTime = [] ; +for i = 0.01:0.01:10 + TransientTime(end+1) = stepinfo(feedback(sys, i)).TransientTime ; +end +[minimum, min_index] = min(TransientTime) +k = min_index * 0.01; +lsim(feedback(sys,k), u, t) ; +H = -3 +%% +sys_CL = feedback(sys,k); +[y, tOut] = lsim(sys_CL, -3.*u, t); +% plot(t, Cw(L)*y, t, u) +eig_cont_CL = eig(sys_CL); +figure; +subplot(1,2,1) ; +plot(eig_cont_CL, 'x'); +hold off; + +subplot(1,2,2); +eig_zoh1 = eig(c2d(sys_CL, Ts1, 'zoh')) ; +eig_zoh2 = eig(c2d(sys_CL, Ts2, 'zoh')) ; +eig_zoh3 = eig(c2d(sys_CL, Ts3, 'zoh')) ; +plot(eig_zoh1,'x'); +hold on; +plot(eig_zoh3,'x'); +hold off; +%% +sys_CL_Ts = c2d(sys_CL, 10, 'zoh'); +figure +step(sys_CL_Ts) +%% +K = lqr(sys, eye(size(A)), 1) +sys_CL_lqr = ss(A-B*K, B*H, C, 0); +lsim(sys_CL_lqr, u, t); \ No newline at end of file diff --git a/Simulink.slx b/Simulink.slx new file mode 100644 index 0000000..8654613 Binary files /dev/null and b/Simulink.slx differ diff --git a/Simulink.slxc b/Simulink.slxc new file mode 100644 index 0000000..0cbd9ae Binary files /dev/null and b/Simulink.slxc differ