Matlab. Could you please answer part 1. × ENGR 102-Homework 3. https ecampuswww.
ID: 3911459 • Letter: M
Question
Matlab. Could you please answer part 1.
× ENGR 102-Homework 3. https ecampuswww.edu/bbcswebdav/pid-4939 181-dt-content-rid-415568131 1805 ENGRT Mr. Spada ENGR 102: Engineering Problem Solving II Homework 3: 1D Arrays and Plots Solve all problems in a single seript file in Matlab. Ensure that your file is saved as LastName_FirstName HW3 before submitting, Submit your file to eCampus by Sunday 7/8/2018 at 11:59 PM. Create sets of reference values for sine, cosine, and tangent for angles ranging from 0 to 2?. Do this in two ways: (1) use a spacing of 0.5 radians, and (2) use 10 linear-spacedl points. Use output functlons to display the values in a manner which will be easily read by the user 1. 2. A spring's displacement in the x direction is defirned by the fallowing equation: where: x is the displacement of the spring at a given time, t; A is the maximunm displacement, and is the angular frequency [dependent upon the spring constant) Find the displacement of the spring from times ranging from 0 to 20 seconds at one second intervals. The maximum displacement af tho spring is known to be 3 inches. The angular frequency is known to be 0.5 radians per second.Explanation / Answer
Code for part 1 is given below. Please do rate it it helped. Thank you.
%method 1: using 0.5 radian as step value
disp('Method 1')
angle1 = 0 : 0.5 : 2*pi;
sine1 = sin(angle1);
cosine1 = cos(angle1);
tangent1 = tan(angle1);
table1 = [angle1 ;sine1; cosine1 ;tangent1];
fprintf('%10s %10s %10s %10s ', 'angle', 'sine', 'cosine', 'tangent');
fprintf('%10.4f %10.4f %10.4f %10.4f ', table1);
%method 2: using linspace() of 10 values
disp('Method 2')
angle2 = linspace(0 , 2*pi, 10);
sine2 = sin(angle2);
cosine2 = cos(angle2);
tangent2 = tan(angle2);
table2 = [angle2; sine2; cosine2; tangent2];
fprintf('%10s %10s %10s %10s ', 'angle', 'sine', 'cosine', 'tangent');
fprintf('%10.4f %10.4f %10.4f %10.4f ', table2);
output
-------
Method 1
angle sine cosine tangent
0.0000 0.0000 1.0000 0.0000
0.5000 0.4794 0.8776 0.5463
1.0000 0.8415 0.5403 1.5574
1.5000 0.9975 0.0707 14.1014
2.0000 0.9093 -0.4161 -2.1850
2.5000 0.5985 -0.8011 -0.7470
3.0000 0.1411 -0.9900 -0.1425
3.5000 -0.3508 -0.9365 0.3746
4.0000 -0.7568 -0.6536 1.1578
4.5000 -0.9775 -0.2108 4.6373
5.0000 -0.9589 0.2837 -3.3805
5.5000 -0.7055 0.7087 -0.9956
6.0000 -0.2794 0.9602 -0.2910
Method 2
angle sine cosine tangent
0.0000 0.0000 1.0000 0.0000
0.6981 0.6428 0.7660 0.8391
1.3963 0.9848 0.1736 5.6713
2.0944 0.8660 -0.5000 -1.7321
2.7925 0.3420 -0.9397 -0.3640
3.4907 -0.3420 -0.9397 0.3640
4.1888 -0.8660 -0.5000 1.7321
4.8869 -0.9848 0.1736 -5.6713
5.5851 -0.6428 0.7660 -0.8391
6.2832 -0.0000 1.0000 -0.0000