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!