Write a script that will:
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:6| Question number:13.6
All Answers
total answers (1)
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:6| Question number:13.6
total answers (1)
Ch6Ex13.m
% Script calls functions to:
% prompt for an angle in degrees
% convert to radians
% print both
deg = promptAng;
rad = degRad(deg);
prtDegRad(deg,rad)
promptAng.m
function deg = promptAng
% Prompts for an angle in degrees
% Format of call: promptAng or promptAng()
% Returns an angle in degrees
deg = input('Enter an angle in degrees: ');
end
degRad.m
function rad = degRad(deg)
% Converts an angle from degrees to radians
% Format of call degRad(degrees)
% Returns the angle in radians
rad = deg * pi / 180;
end
prtDegRad.m
function prtDegRad(deg, rad)
% Prints an angle in degrees and radians
% Format of call: prtDegRad(degrees, radians)
% Does not return any values
fprintf('The angle %.1f degrees is \n', deg)
fprintf('equivalent to %.1f radians\n', rad)
end
need an explanation for this answer? contact us directly to get an explanation for this answer