Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added lecture 15
  • Loading branch information
rcc02007 committed Mar 21, 2017
1 parent 0f702b6 commit fb67d3f
Show file tree
Hide file tree
Showing 112 changed files with 1,254 additions and 1 deletion.
2 changes: 1 addition & 1 deletion HW4/README.md
@@ -1,4 +1,4 @@
# Homework #3
# Homework #4
## due 3/1/17 by 11:59pm


Expand Down
Binary file modified lecture_13/octave-workspace
Binary file not shown.
6 changes: 6 additions & 0 deletions lecture_15/.ipynb_checkpoints/lecture_15-checkpoint.ipynb
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
56 changes: 56 additions & 0 deletions lecture_15/animate_eig.m
@@ -0,0 +1,56 @@
function [v,e]=animate_eig(k,m)
% create a series of png's for use in an animation based on
% spring constants [k1,k2,k3]=k
% and
% masses
% [m1,m2]=m

% check inputs for m and k
if length(m)==1
m1=m;
m2=m;
else
m1=m(1);
m2=m(2);
end
if length(k)==1
k1=k; k2=k; k3=k;
else
k1=k(1);
k2=k(2);
k3=k(3);
end
setdefaults
K=[k1/m1+k2/m1,-k2/m1;-k3/m2,k2/m2+k3/m2];
[v,e]=eig(K);
w1=e(1,1); w2=e(2,2);
scale = 0.5; % the magnitude of oscillations is not important for vibrational modes
% just set scale to 1/2 for nice plots
% the eigenvector magnitude is independent of the solution
X11=v(1,1)*scale; X12=v(2,1)*scale;
X21=v(1,2)*scale; X22=v(2,2)*scale;
f11=@(t) X11*sin(w1*t); f12=@(t) X12*sin(w1*t);
f21=@(t) X21*sin(w2*t); f22=@(t) X22*sin(w2*t);
f=figure();
time=linspace(-1,4);
% create a loop to plot the position over time where mass 1 and 2 start at x=1 and x=2 m
% then for the next vibrational mode, mass 1 and 2 start at x=3 and x=4 m

for i=1:length(time)
t=time(i);
plot(f11(t)+1,0,'rs',f11(time+t)+1,-time,...
f12(t)+2,0,'rs',f12(time+t)+2,-time,...
f21(t)+3,0,'bo',f21(time+t)+3,-time,...
f22(t)+4,0,'bo',f22(time+t)+4,-time)
axis([0 6 -4 1])
title('Vibration Modes')
xlabel('position (m)')
ylabel('time (s)')
filename=sprintf('output/%05d.png',i);
% another option for saving a plot to a png is the 'print' command
print(filename)
end
% this is a system command to use ImageMagick's cli 'convert' to create an animated gif
% if you don't have ImageMagick installed, comment this next line
system ("convert -delay 10 -loop 0 output/*png eigenvalues.gif")
end
Binary file added lecture_15/eig_200_100_40_20.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lecture_15/eig_200_100_40_50.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lecture_15/eig_200_40.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fb67d3f

Please sign in to comment.