While-end statement using factorial(),abs() and cos()
3 views (last 30 days)
Show older comments
I am having trouble understanding what I need to accomplish in part c of this lab. This is my code so far.
if true%
clear all;
clc;
close all;
x=input('Enter a value for x (in radians): ');
threshold=input('Enter a threshold in the range (0,1): ');
while ( threshold < 0 || threshold > 1)
fprintf('Incorrect input, please try again.\n');
threshold = input ('Enter a threshold in the range (0,1): ');
end
How would I that formula?? I already have the user input x and threshold value. I need to use a while loop to compare the value of mycos(x) and cos(x) until the difference between the two is less than or equal to the threshold value entered by the user. Then I need to determine the number of terms summed to achieve the accuracy...
Really not sure where to start on this part. The while loop it a lot more complex then the loop used for the previous step. Any help would be greatly appreciated.
while (mycos(x) - cos(x) <= threshold)<--really not sure how to start and why I need to use factoral, abs.
0 Comments
Accepted Answer
More Answers (1)
See Also
Categories
Find more on Matrix Indexing 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!