Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 1 (20 Points): while loop After studying Example 9.3 (P. 323) – this is

ID: 3806908 • Letter: P

Question

Problem 1 (20 Points): while loop

After studying Example 9.3 (P. 323) – this is the problem to convert units from radians to degrees – create a single m-file that produces two tables:

(a) The first table considers the range of angles between 5 and 180 deg with an increment of 5 deg. Notice that you should still end up with a matrix containing 36 rows.

(b) The second table considers angles between 10 and 180 deg with an increment of 10 deg. Notice that, this time, you will end up with a matrix containing 18 rows.

Submission: 1 m-file and a printout of the command window.

Explanation / Answer

%matlab code

%part (a)

degree = linspace(5,180,36);
matrix = zeros(length(degree),2);
for i=1:36
matrix(i,1) = degree(i);
matrix(i,2) = (degree(i)*pi)/180;
end
disp(matrix);
%{
output:
5.0000e+00 8.7266e-02
1.0000e+01 1.7453e-01
1.5000e+01 2.6180e-01
2.0000e+01 3.4907e-01
2.5000e+01 4.3633e-01
3.0000e+01 5.2360e-01
3.5000e+01 6.1087e-01
4.0000e+01 6.9813e-01
4.5000e+01 7.8540e-01
5.0000e+01 8.7266e-01
5.5000e+01 9.5993e-01
6.0000e+01 1.0472e+00
6.5000e+01 1.1345e+00
7.0000e+01 1.2217e+00
7.5000e+01 1.3090e+00
8.0000e+01 1.3963e+00
8.5000e+01 1.4835e+00
9.0000e+01 1.5708e+00
9.5000e+01 1.6581e+00
1.0000e+02 1.7453e+00
1.0500e+02 1.8326e+00
1.1000e+02 1.9199e+00
1.1500e+02 2.0071e+00
1.2000e+02 2.0944e+00
1.2500e+02 2.1817e+00
1.3000e+02 2.2689e+00
1.3500e+02 2.3562e+00
1.4000e+02 2.4435e+00
1.4500e+02 2.5307e+00
1.5000e+02 2.6180e+00
1.5500e+02 2.7053e+00
1.6000e+02 2.7925e+00
1.6500e+02 2.8798e+00
1.7000e+02 2.9671e+00
1.7500e+02 3.0543e+00
1.8000e+02 3.1416e+00
%}


%part (b)

degree = linspace(10,180,18);
matrix = zeros(length(degree),2);
for i=1:18
matrix(i,1) = degree(i);
matrix(i,2) = (degree(i)*pi)/180;
end
disp(matrix);
%{
output:
10.00000 0.17453
20.00000 0.34907
30.00000 0.52360
40.00000 0.69813
50.00000 0.87266
60.00000 1.04720
70.00000 1.22173
80.00000 1.39626
90.00000 1.57080
100.00000 1.74533
110.00000 1.91986
120.00000 2.09440
130.00000 2.26893
140.00000 2.44346
150.00000 2.61799
160.00000 2.79253
170.00000 2.96706
180.00000 3.14159
%}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote