This week\'s exercise is based on problem 4.17 in your MATLAB book^1. The airpla
ID: 1994631 • Letter: T
Question
This week's exercise is based on problem 4.17 in your MATLAB book^1. The airplane shown is flying in a circular path with radius rho, the bottom of which is located at a height h above the ground, with constant tangential velocity nu. The airplane's position is being tracked by radar station on the ground. In this exercise, you will be calculating the airplane's radial distance r and elevation theta relative to the radar station. Start MATLAB, navigate to the directory where you want to save your work, and start a new m-file called "W10.m". Your program should do the following: PART 1: using the 'input' command, prompt the user for nu, rho, and h. (When testing your code, try using the values nu = 50 m/s, rho = 2000m, and h = 500m as shown in your book). PART 2: using the 'linspace' command, create a 100-element time vector going from zero to the time at which infinity = 90 degree. To calculate the upper time limit, calculate the circumferential distance traveled between infinity = 0 degree and infinity = 90 degree, then divide by tangential velocity to get time. PART 3: create a vector for a as a function of time, using the following relationship: alpha(t) = nu/rho t PART 4: create vectors that represent the horizontal and vertical (x, y) coordinates of the airplane relative to the radar station, using the following equations: x(alpha) = rho sin alpha y(alpha) = rho(1 - cos alpha) + h PART 5: convert your rectangular (x, y) coordinates into polar (r, theta) coordinates. PART 6: using the 'min' command, determine the minimum value of theta, and the position in the theta vector where the minimum occurs. Use the latter as an array index to find the values of t and r where theta is minimized. PART 7: using the 'fprintf' command, display a message in the command window that includes the minimal value of theta, as well as the t and r values where the minimum occurs. PART 8: combine your t, r, and theta vectors intoTsingle 3 times 100 matrix variable called voutput. Then, write this matrix to an output file using the following steps: a. Use the 'fopen'command to create a new file called 'output.doc'. b. Use the 'fprintf' command to write the column headers 'TIME', 'DISTANCE', and 'ANGLE' to your output.doc file c. Use the 'fprintf' command to write your voutput matrix to the output.doc file d. Use the 'fclose' command to close your output file. When finished, upload BOTH files (W10.m AND output.doc) to Blackboard using the link provided. REFERENCE Gilat A., MATLAB: An Introduction with Applications, 4^th ed., Wiley, Hoboken, NJ, 2011.Explanation / Answer
The following is the required MATLAB function:
function w10
clc % Clears the command window screen
v=input('enter the value for v ');
Rho=input('enter the value for Rho ');
h=input('enter the value for h ');
t=Rho*pi/2/v;
fprintf(' The time at which alpha is 90 deg is %f ',t)
i=1;
fprintf(' Rho Velocity h')
fprintf(' %3.3f %3.3f %3.3f',Rho,v,h)
fprintf(' ')
disp('Time(t) Theta(radians) Radius(m)')
for x=linspace(0,t)
t(i)=x;
Alpha(i)=(v*t(i))/Rho;
x(i)=Rho*sin(Alpha(i));
y(i)=Rho*(1-cos(Alpha(i)))+h;
[Theta(i),r(i)]=cart2pol(x(i),y(i));
fprintf(' %3.3f %3.3f %3.3f',t(i),Theta(i),r(i))
i=i+1;
end
[Tmin,I]=min(Theta);
fprintf(' The minimum value of Theta and the values of t and r corresponding to Theta minimum are %3.3f %3.3f %3.3f ',Tmin,t(I),r(I));
end
Save the file with .m extension and recall the function in command work space.
The following is the output:
enter the value for v
50
enter the value for Rho
2000
enter the value for h
500
The time at which alpha is 90 deg is 62.831853
Rho Velocity h
2000.000 50.000 500.000
Time(t) Theta(radians) Radius(m)
0.000 1.571 500.000
0.635 1.507 501.257
1.269 1.445 505.009
1.904 1.384 511.201
2.539 1.324 519.743
3.173 1.267 530.521
3.808 1.213 543.397
4.443 1.162 558.225
5.077 1.115 574.849
5.712 1.070 593.115
6.347 1.029 612.871
6.981 0.991 633.974
7.616 0.956 656.287
8.251 0.924 679.688
8.885 0.895 704.061
9.520 0.868 729.304
10.155 0.843 755.323
10.789 0.821 782.035
11.424 0.801 809.364
12.059 0.782 837.244
12.693 0.766 865.615
13.328 0.750 894.423
13.963 0.737 923.620
14.597 0.724 953.164
15.232 0.713 983.016
15.867 0.703 1013.142
16.501 0.694 1043.511
17.136 0.686 1074.095
17.771 0.679 1104.869
18.405 0.673 1135.809
19.040 0.667 1166.896
19.675 0.663 1198.109
20.309 0.658 1229.433
20.944 0.655 1260.851
21.579 0.652 1292.349
22.213 0.649 1323.913
22.848 0.647 1355.531
23.483 0.646 1387.192
24.117 0.645 1418.885
24.752 0.644 1450.600
25.387 0.644 1482.328
26.021 0.644 1514.061
26.656 0.644 1545.791
27.291 0.644 1577.509
27.925 0.645 1609.210
28.560 0.647 1640.885
29.195 0.648 1672.530
29.829 0.650 1704.137
30.464 0.652 1735.701
31.099 0.654 1767.218
31.733 0.656 1798.680
32.368 0.658 1830.085
33.003 0.661 1861.426
33.637 0.664 1892.699
34.272 0.667 1923.900
34.907 0.670 1955.025
35.541 0.674 1986.070
36.176 0.677 2017.030
36.811 0.681 2047.902
37.445 0.684 2078.682
38.080 0.688 2109.367
38.715 0.692 2139.954
39.349 0.696 2170.438
39.984 0.701 2200.816
40.619 0.705 2231.086
41.253 0.709 2261.244
41.888 0.714 2291.288
42.523 0.718 2321.214
43.157 0.723 2351.019
43.792 0.728 2380.700
44.427 0.733 2410.256
45.061 0.737 2439.683
45.696 0.742 2468.977
46.331 0.747 2498.138
46.965 0.753 2527.162
47.600 0.758 2556.047
48.235 0.763 2584.790
48.869 0.768 2613.388
49.504 0.774 2641.840
50.139 0.779 2670.143
50.773 0.784 2698.295
51.408 0.790 2726.293
52.043 0.796 2754.135
52.677 0.801 2781.820
53.312 0.807 2809.343
53.947 0.812 2836.705
54.581 0.818 2863.902
55.216 0.824 2890.932
55.851 0.830 2917.793
56.485 0.836 2944.484
57.120 0.842 2971.002
57.755 0.847 2997.345
58.389 0.853 3023.511
59.024 0.859 3049.498
59.659 0.865 3075.305
60.293 0.872 3100.929
60.928 0.878 3126.369
61.563 0.884 3151.622
62.197 0.890 3176.687
62.832 0.896 3201.562
The minimum value of Theta and the values of t and r corresponding to Theta minimum are
0.644 26.021 1514.061
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.