Write the function sideOf which accepts one side of a right-angle triangle, a or b, and the hypotenuse c as input arguments and outputs the other side b or a.

1 view (last 30 days)
function side2Length = sideOf(side1Length, c)
side2Length = sqrt (c^2-side1Length^2);
:( its giving wrong answer

Answers (1)

ANKUR KUMAR
ANKUR KUMAR on 7 Jan 2018
sideOf(3,5)
function b=sideOf(a,c)
b=sqrt(c^2 - a^2);
end
Just one line function. Use the above script. It works if you are using MATLAB version 2016b or later, ortherwise create this function separately and write sideOf(3,5) in command window or in script.

Categories

Find more on Multidimensional Arrays 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!