MATLAB: Diagonal of a quadrilateral

diagonal of a quadrilateralMATLAB

How do you determine the length of one diagonal of a quadrilateral using a user defined function. The input parameters are AB, BC, CD, DA, AC. Find DB. Here is what I have so far: Function(quadrilateral): function x=quadrilateral(AB,BC,CD,DA,AC) x=DB=(DA*(BC)+AB*(CD))/AC end Script: x=quadrilateral(9,3,4,5,6) disp(x) How do I define the function 'x' in such a way so that the equation for finding the diagonal of a quadrilateral is assigned to it?

Best Answer

Just get rid of the "DB ="
function x=quadrilateral(AB,BC,CD,DA,AC)
x=(DA*(BC)+AB*(CD))/AC;
Alternatively, of course, you could also rename x to DB in your function, if you prefer this:
function DB=quadrilateral(AB,BC,CD,DA,AC)
DB=(DA*(BC)+AB*(CD))/AC;
Related Question