While-end statement using factorial(),abs() and cos()
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!