In: Advanced Math
%%Matlab code Using for loop to create a table that convert
angle values from degrees to radians
clear all
close all
%Answering question 6.
fprintf('Answering question 6. ')
c=0; %counter for 'for' loop
fprintf('Table for degree to radian conversion using for loop.
')
fprintf(' Degree Rad ')
%loop for degree to rad conversion
for i=1:4:181
c=c+1; %counter
increament
%angle in degree with increament 4
angle_deg(c)=i-1;
%angle for deg to rad conversion
angle_rad(c)=angle_deg(c)*(pi/180);
%printing the table
fprintf(' %3.0f %f
',angle_deg(c),angle_rad(c))
end
%Answering question 7.
fprintf('Answering question 7. ')
fprintf('Table for degree to radian conversion using vectorization.
')
fprintf(' Degree Rad ')
%vectorization form for angle in degree
angl_deg=0:4:180;
%converted angle into rad
angl_rad=angl_deg*(pi/180);
%prnting the result
anggl=[angl_deg' angl_rad'];
fprintf(' %3.0f %f ',anggl.')
%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%