one script two anonymous functions

I do not undestand when I wrong in my code
thank you so much for yor help
ThirdSide = @(a,b,C) sqrt(a^2+b^2-(2*a*b*cos(C)));
TriangleArea = @(a,b,C) ((a*b)/2)*sin(C);
SideC =ThirdSide(5,8,50*pi/180)
AreaABC=TriangleArea(5,8,50*pi/180)

回答 (2 件)

Steven Lord
Steven Lord 2020 年 10 月 13 日

1 投票

Based on the problem description I'm guessing C is an angle in degrees, not radians. If that's the case take a look at the sind function.
Fanele
Fanele 2022 年 11 月 6 日
移動済み: Image Analyst 2022 年 11 月 6 日

0 投票

ThirdSide=@(a,b,C) sqrt(a^2+b^2-2*a*b*cos(C*pi/180))
ThirdSide = function_handle with value:
@(a,b,C)sqrt(a^2+b^2-2*a*b*cos(C*pi/180))
TriangleArea=@(a,b,C) (((a*b)/2)*sin(C*pi/180))
TriangleArea = function_handle with value:
@(a,b,C)(((a*b)/2)*sin(C*pi/180))
SideC=ThirdSide(5,8,50)
SideC = 6.1300
AreaABC=TriangleArea(5,8,50)
AreaABC = 15.3209

カテゴリ

ヘルプ センター および File ExchangeLinear Algebra についてさらに検索

製品

質問済み:

2020 年 10 月 13 日

移動済み:

2022 年 11 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by