Help with script please!!! pic included!!

I really need help on how to approach the problem. Does anyone know how to go about it or are there any examples like this one? Thank you so much!!!! the picture attached has the problem.
this is what I have this so far:
x= input('Please provide a radian:');
if cos(x)< 10^-20
disp('Invalid value.');
else
cos(x)>=10^-20;
tan(x)=abs(sin(x)/cos(x));
fprint('Tan(x) of the value is %f\n',tan(x));
end

4 件のコメント

per isakson
per isakson 2014 年 11 月 11 日
編集済み: per isakson 2014 年 11 月 11 日
Your approach is fine. There are, however, a few syntax errors in your code. Did you get any error messages?
Mikhail
Mikhail 2014 年 11 月 11 日
just delete line cos(x)>=10^-20;
Pam
Pam 2014 年 11 月 11 日
I did receive an error message. I am stuck in how to get my program to do the conversion of degree and radian and I get an error for the tan equation
Image Analyst
Image Analyst 2014 年 11 月 11 日
You can use the "d" versions so you don't need to convert and you can just enter the values directly in degrees: cosd(), sind(), tand(), atan2d(), etc.

サインインしてコメントする。

 採用された回答

Image Analyst
Image Analyst 2014 年 11 月 11 日

0 投票

Try this:
x= input('Please provide a radian: ');
if cos(x)< 10^-20
disp('Invalid value.');
else
tanx = abs(sin(x)/cos(x));
fprintf('Tan(x) of the value %f is %f\n', x, tanx);
end

6 件のコメント

Pam
Pam 2014 年 11 月 11 日
Ok thank you I will try this out as soon as I have access to my laptop
Pam
Pam 2014 年 11 月 11 日
編集済み: Image Analyst 2014 年 11 月 11 日
I tried it out. Thank you. I was just wondering if the number showing is in degrees or radians.
>> tangent
Please provide a radian: 60
Invalid value.
>> tangent
Please provide a radian: 0
Tan(x) of the value 0.000000 is 0.000000
>> tangent
Please provide a radian: 30
Tan(x) of the value 30.000000 is 6.405331
Image Analyst
Image Analyst 2014 年 11 月 11 日
it's in radians because you're not using the "d" version of the functions.
Pam
Pam 2014 年 11 月 12 日
I am not sure if the question is asking for it to be in radians or in degrees the last part confuses me. Should I add "d"?
Image Analyst
Image Analyst 2014 年 11 月 12 日
I don't know. I have not seen "the question".
Pam
Pam 2014 年 11 月 12 日
oh i added it ti this question it is attatched

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeIntroduction to Installation and Licensing についてさらに検索

質問済み:

Pam
2014 年 11 月 11 日

コメント済み:

Pam
2014 年 11 月 12 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by