This is the first of several lab assignments whose overall goal is to study the
ID: 2326070 • Letter: T
Question
This is the first of several lab assignments whose overall goal is to study the behavior of a simple mechanical system. Consider the system shown in Figure 1. The bars are rigid anti connected to a piston. The angle theta_1 will be given a function of time, but it will have noise. You will study the effects of noise in a signal and the effect on numerical derivatives. You will write a Matlab script to compute derivatives of a smooth and noisy signal (in this case, the signal would be theta_1(t). Generate theta_1(t) = sin(pi t), t [0, 1], with 100 intervals. Analytically compute the velocity, theta (t), and the acceleration, theta _1(t). Use u central difference approximation to numerical compute theta_1(t) and theta_1(t) Now generate a noisy theta_1(t) by adding noise using the following Matlab command: theta = sin(pi*t) + 0.001* randn (1, size(t, 2)) Use a central difference approximation to numerical compute theta_1(t) and theta_1(1) for the noisy set of data. Plot theta_1(t). theta_ 1(t). theta_ 1(t) for the exact, numerical, anti noisy. You plot should be properly labeled, with readable font sizes. line thicknesses, etc. Submission Instructions There should be exactly two files submitted and discussion in the submission text box: A pdf file of the resulting plot, named "Lab7-person#.pdf" Your Matlab m-file. named ''Lab7_person#.m" A short (2-3 sentence) describing your observations.Explanation / Answer
%%% MATLAB Code
clc
clear all
t = 0:0.01:1;
%% Analytical
theta1 = sin(pi.*t);
theta1_dot = pi*cos(pi.*t);
theta1_ddot = -pi^2*sin(pi.*t);
%% Numerical
theta1_num_dot = zeros(101);
theta1_num_ddot = zeros(101);
theta1_num_dot(1) = (theta1(2)-theta1(1))/0.01;
for i = 2:100
theta1_num_dot(i) = (theta1(i+1)-theta1(i-1))/(2*0.01);
end
theta1_num_ddot(1) = (theta1(3)-2*theta1(2)+theta1(1))/(0.01^2);
for i = 2:100
theta1_num_ddot(i) = (theta1(i+1)-2*theta1(i)+theta1(i-1))/(0.01^2);
end
%plot(t,theta1,t,theta1_dot,t,theta1_ddot,t,theta1_num_dot,t,theta1_num_ddot);
%% Numerical noise
temp = 0.001*randn(1,size(t,2));
for j = 1:101
theta1_noise(j) = theta1(j) + temp(j);
end
theta1n_num_dot = zeros(101);
theta1n_num_ddot = zeros(101);
theta1n_num_dot(1) = (theta1_noise(2)-theta1_noise(1))/0.01;
for i = 2:100
theta1n_num_dot(i) = (theta1_noise(i+1)-theta1_noise(i-1))/(2*0.01);
end
theta1n_num_ddot(1) = (theta1_noise(3)-2*theta1_noise(2)+theta1_noise(1))/(0.01^2);
for i = 2:100
theta1n_num_ddot(i) = (theta1_noise(i+1)-2*theta1_noise(i)+theta1_noise(i-1))/(0.01^2);
end
figure (1)
plot(t,theta1,t,theta1_noise,'linewidth',2);
title('Angular displacement')
xlabel('time (sec)')
ylabel('Angular displacement (rad)')
grid on
figure (2)
plot(t,theta1_dot,t,theta1_num_dot,t,theta1n_num_dot,'linewidth',2);
title('Angular velocity')
xlabel('time (sec)')
ylabel('Angular velocity (rad/sec)')
grid on
figure (3)
plot(t,theta1_ddot,t,theta1_num_ddot,t,theta1n_num_ddot,'linewidth',2);
title('Angular acceleration')
xlabel('time (sec)')
ylabel('Angular acceleration (rad/sec^2)')
grid on
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.