Assignment 1 Matlab code for numerical convolution PDF

Title Assignment 1 Matlab code for numerical convolution
Course Dynamics and Control
Institution Royal Melbourne Institute of Technology
Pages 5
File Size 35.1 KB
File Type PDF
Total Downloads 116
Total Views 155

Summary

Assignment 1 Matlab code for numerical convolution, Assignment 1 Matlab code for numerical convolution, Assignment 1 Matlab code for numerical convolution...


Description

%Numerical Convolution

%Assignment 1 Data m=1+2+3+4+5+6+7; k=1*2*3*4*5*6*7; c=-567; w_n=sqrt(k/m); zeta=c/(2*sqrt(k*m)); w_d = w_n*sqrt(1-zeta^2);

%mass, kg: Sum of student number %stiffness: Student digits multiplied %Damping Nm: Last three numbers of student number %Natural frequency Rad/s %Damping Ratio, no units %Gives damped frequency

%all Functions are double precision arrays now %Create a vector of time: t=linspace(0,15,1000); %Time, s %Input force %Ft= Heavyside Function calculated from assignment powerpoint slide. %unit impulse repsonse gt=1./(m.*w_d).*exp(-zeta.*w_n.*t).*sin(w_d.*t); figure (1) plot(t,gt,'b'); %plot unit impulse response title 'unit Impulse Response'; xlabel 'time (s)'; ylabel 'displacement (m)'; grid on %convolution Yt=conv(Ft,gt); %limit convolution to first half %total solution will be 2*(number of impulses -1) %Yt=Yt(1:TIMESTEP); %multiply on timestep 15/100 %Yt=Yt*(15/TIMESTEP); %plot figure (2) plot(t,Yt,'r') %put your titles in between the purple -> '' title ''; xlabel ''; ylabel ''; % Plot the Poles and zeros syms sG s = tf('s'); % Denominator of the transfer function G = 1/(m*s^2 + c*s + k); % Derives the transfer function

% Plot poles and zeros plot figure(1) pzplot(G); title '';

syms t %input force equation. %Ft= Heavyside Function calculated from assignment powerpoint slide. % Plot of force from 0 to 5 seconds figure(1) fplot(Ft,[0,5]); title ''; xlabel ''; ylabel '';

* NEW MATAB CODE*

syms t s T y(t) y0 Y(s) %Assignment 1 Data m=1+2+3+4+5+6+7; k=1*2*3*4*5*6*7; c=-567; w_n=sqrt(k/m); zeta=c/(2*sqrt(k*m)); w_d = w_n*sqrt(1-zeta^2);

%mass, kg: Sum of student number %stiffness: Student digits multiplied %Damping Nm: Last three numbers of student number %Natural frequency Rad/s %Damping Ratio, no units %Gives damped frequency

%all Functions are double precision arrays now % input force equation. %Ft= Heavyside Function calculated from assignment powerpoint slide. Fs = laplace(Ft); % Laplace of the input force h = m*diff(y,t,t) + c*diff(y,t) + k*y; % Homogenous equation H(s) = laplace(h); % Laplace of the homogenous eq Ys = Fs/H(s); % Inverse Laplace Yt = ilaplace(Ys); % Outputs the inverse Laplace of Ys

% Plot of transient response % plot from 0 to 15 sec figure (3) t=[0,15] fplot(Yt,t,'r') title ''; xlabel ''; ylabel '';

*NEW MATLAB CODE*

function dydt=odefun(t,y) %Assignment 1 Data m=1+2+3+4+5+6+7; k=1*2*3*4*5*6*7; c=-567;

%mass, kg: Sum of student number %stiffness: Student digits multiplied %Damping Nm: Last three numbers of student number

%Input force %Ft= Heavyside Function calculated from assignment powerpoint slide. %time step from 0 to 15 sec t=[0 15]

%state space form dydt=[y(2);-(k./m).*y(1)-(c./m).*y(2)+Ft./m]; %odefun here references the function we created above syms t [t,y] = ode45(odefun,[0 15],[0; 0]); plot(t,y(:,1)) title ''; xlabel ''; ylabel ''; end...


Similar Free PDFs