example - while (a <= 0) disp('angle must be positive')...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function [a,b] = calc_sides(c,theta) % given the hypotenuse and angle of a right % triangle, calculate other two sides of % triangle c=2; theta=4; a = c * cos(theta); b = c * sin(theta); end get_angle_and_hyp.m function [h,a] = get_angle_and_hyp % prompt the user for a values for angle % and hypotenuse, error check to be sure % value is >= 0 % hypotenuse h=input('enter the hypotenuse: '); while (h <= 0) disp('hypotenuse must be positive') h=input('enter the angle: '); end % angle a=input('enter the angle: ');
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: while (a <= 0) disp('angle must be positive') a=input('enter the angle: '); end end calc_sides.m end righttri.h % Jackie Horton % this script calls a function to prompt the user and read in values for % the hypotenuse and the angle (in radians), and then calls a function to % calculate and return the lengths of % sides a and b, and a function to % print out all values in a % nice sentence format clc clear all [c,angle]=get_angle_and_hyp; {a,b]=calc_sides(c,angle); print_values(a,b,c,angle);...
View Full Document

This note was uploaded on 03/22/2012 for the course ENGINEERIM 1000 taught by Professor Ee during the Spring '12 term at Vermont Tech.

Ask a homework question - tutors are online