# asin_yourlogin - % ---- INPUTS ----% % ---- CALCULATIONS...

This preview shows pages 1–2. Sign up to view the full content.

function [asin_val] = asin_yourlogin(x) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Programmer(s) and Purdue Email Address(es): % 1. ENGR Faculty/Staff % % Section #: ALL % % Assignment #: Homework 4 Problem 3 % % Academic Integrity Statement: % % I/We have not used source code obtained from % any other unauthorized source, either modified % or unmodified. Neither have I/we provided access % to my/our code to another. The project I/we am/are % submitting is my/our own original work. % % asin_yourlogin: checks that the input argument is between -1 and 1 and, % if so, calculates the asin of that value. Otherwise, it returns "value % must be between -1 and 1" % % INPUTS: List them below one line per input argument % x - input value to be calculated (must be between -1 and 1) % OUTPUTS: List them below line per output argument % asin_val - the value of the asin of x % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % ---- INPUTS ----% % ---- CALCULATIONS ----if x&gt;=-1 &amp;&amp; x&lt;=1 % Checks if value is between -1 and 1 asin_val = asin(x); % calculates asin for values that are valid else asin_val = 'value must be between -1 and 1'; % assigns error message to output end e % Alternate logic % if x&lt;-1 || x&gt;1 % Checks if value is outside of range % asin_val = 'value must be between -1 and 1'; % assigns error message to output % else % asin_val = asin(x); % calculates asin for values that are valid % end % %---- Test Cases ----% i: x = 0.5 % &gt;&gt; asin_x = asin_yourlogin(0.5) % &gt;&gt; asin_x = 0.5236 % ii: x = -1.9 % &gt;&gt; asin_x = asin_yourlogin(-1.9) % &gt;&gt; asin_x = value must be between -1 and 1 % iii: x = 0 % &gt;&gt; asin_x = asin_yourlogin(0) % &gt;&gt; asin_x = 0 % iv: x = 3 % &gt;&gt; asin_x = asin_yourlogin(3) % &gt;&gt; asin_x = value must be between -1 and 1...
View Full Document

## asin_yourlogin - % ---- INPUTS ----% % ---- CALCULATIONS...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online