diff --git a/.gitignore b/.gitignore index 92103baad1e22b301d30a7041db6f08f7b51c3b3..0cab372ccdb5f884c1048789d724b00e01e95ca5 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ *.out *.synctex.gz *.bak +*.mp4 diff --git a/pend01.m b/pend01.m index 8c8e53f871fb06a2418b4f9287e4f6621e6ffdfd..d2adc1917a04c991824173fb8c42c50544e21a49 100644 --- a/pend01.m +++ b/pend01.m @@ -2,7 +2,7 @@ l1 = 0.5; % Pendulum lengths [meter] l2 = 0.1; fs = 50; % Plotting rate [Hz] h = 1/fs; -maxt = 4; % Simulation time [sec] +maxt = 3; % Simulation time [sec] g = 9.81; a1 = g/l1; a2 = g/l2; @@ -112,6 +112,7 @@ phi2 = y(:,2); pos = y(:,3); u = y(:,4); +clear F save results diff --git a/plotit.m b/plotit.m index dbc92e0db427c43c133f82c23d34e6424954d691..2ccbfb4e6f13168685263aaf7f7762acde1fc35a 100644 --- a/plotit.m +++ b/plotit.m @@ -25,6 +25,7 @@ load results.mat %Create the markers representing the system which will %vary according to calculated positions +figure(9) subplot(3,2,[1 3 5]) h1 = plot(0,0,'MarkerSize',30,'Marker','.','LineWidth',2,'Color','b'); @@ -68,12 +69,12 @@ title('Position') % Animation for i=1:length(t)-1 + figure(9) if (ishandle(h1)==1) %check figure is plotting Xcoord=[pos(i),pos(i)-l1*sin(phi1(i))]; Ycoord=[0,l1*cos(phi1(i))]; %update markers to reflect x and y cords set(h1,'XData',Xcoord,'YData',Ycoord); - drawnow; end if (ishandle(h2)==1) %check figure is plotting Xcoord=[pos(i),pos(i)-l2*sin(phi2(i))]; diff --git a/readme.txt b/readme.txt index 1582a03ef1f4dc97e6d236ebf665d63c9cf6fb18..20dfd35ecaff21b0e12d872773324abcad33e717 100644 --- a/readme.txt +++ b/readme.txt @@ -4,4 +4,5 @@ with two inverted pendulums on a moving cart. pend01.m - LQG design for linearized system plotit.m - Animation (2D, without noise) pendulumsoncart.mp4 - Film of resulting controller -results.mat - simulation results +results.mat - result file + diff --git a/results.mat b/results.mat index 334b4a9af25602bc8c4f64db0727caa7c122cf28..7e40163f8752bac91691a1b4e2a5a72422691e30 100644 Binary files a/results.mat and b/results.mat differ