While loop homework problem
1 view (last 30 days)
Show older comments
For any number between -1 and 1, your program calculates and outputs the arccosine and arcsine of the number in both degrees and radians. (Example: if you enter 0, arccosine is either 90 degrees or π/2 radians, and 270 degrees or 3π/2 radians.) For your convenience, your answers can be between 0 and 180 degrees (π).
This is what I've been doing. I know its wrong...The thing is it has to be like beginner MATLAB level language. i=-1;
Bye the way it is bad to use "i" as variables in Matlab because it thinks "i" or "j" as the square root of -1 (Imaginary number)
Harry MacDowel on 11 Oct 2011
I felt a bit bored so I do the coding for you. Also I might have use for this in near future. Just run arcCosSin in command window.
Next time try a bit harder to do the homework yourself. You could get a lot of Matlab programming tips through Google.
function  = arcCosSin()
% Written by GLO on 11.Oct.2011
inputnum = input('Please Enter a number between -1 and 1 for the arcCos and arcSin: ');
if (inputnum<-1 || inputnum>1)
fprintf('\nThis program only gives the answer for input between -1 and 1\n');
sinDeg = asind(inputnum);
sinRad = asin(inputnum);
cosDeg = acosd(inputnum);
cosRad = acos(inputnum);
fprintf('ArcSin in Degree is: %0.2f\n',sinDeg);
fprintf('ArcSin in Radian is: %0.5f\n',sinRad);
fprintf('ArcCos in Degree is: %0.2f\n',cosDeg);
fprintf('ArcCos in Radian is: %0.5f\n',cosRad);
More Answers (1)
for ii = -1:0.001:1
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!