Please give all steps. Also, please be specific on what to enter into Matlab and
ID: 3554070 • Letter: P
Question
Please give all steps. Also, please be specific on what to enter into Matlab and what not to enter.
Write a function called area_yourID# which will find the area in acres and the perimeter in feet of a plot of land, given the x-y coordinates for points P1, P2. P3, and P4. comprising the four corners of the land. Make the function inter-active such that the user is told what the function is about, and then prompted to type the values for these 8 values from the keyboard. Submit the assignment into the dropbox.Explanation / Answer
dropbox-link: https://dl.dropboxusercontent.com/u/78383401/chegg/matlab/t.m
driver matlab script: file t.m
%taking data from the user for vertices coordinate in feets
input_p1_x = str2double(input('Enter x coordinate for vertex P1: ','s'));
input_p1_y = str2double(input('Enter y coordinate for vertex P1: ','s'));
input_p2_x = str2double(input('Enter x coordinate for vertex P2: ','s'));
input_p2_y = str2double(input('Enter y coordinate for vertex P2: ','s'));
input_p3_x = str2double(input('Enter x coordinate for vertex P3: ','s'));
input_p3_y = str2double(input('Enter y coordinate for vertex P3: ','s'));
input_p4_x = str2double(input('Enter x coordinate for vertex P4: ','s'));
input_p4_y = str2double(input('Enter y coordinate for vertex P4: ','s'));
p1=[input_p1_x,input_p1_y];
p2=[input_p2_x,input_p2_y];
p3=[input_p3_x,input_p3_y];
p4=[input_p4_x,input_p4_y];
[ans_area,ans_parameter]=Area(p1,p2,p3,p4);
disp(sprintf('The parameter of quadrilateral is: %f feets',ans_parameter));
%acres = (square feet) / 43560
disp(sprintf('The parameter of quadrilateral is: %f acres',ans_area/43560 ));
_______________________________________________________________________________________________
dropbox-link: https://dl.dropboxusercontent.com/u/78383401/chegg/matlab/Area.m
function Area.m: file Area.m
function [ans_area,ans_parameter]= Area(p1,p2,p3,p4)
%simply adding euclidean distance between neighbouring vertices
ans_parameter=sqrt((p1(1)-p2(1))^2+(p1(2)-p2(2))^2)+sqrt((p2(1)-p3(1))^2+(p2(2)-p3(2))^2)+sqrt((p3(1)-p4(1))^2+(p3(2)-p4(2))^2)+sqrt((p4(1)-p1(1))^2+(p4(2)-p1(2))^2);
%standard formula for area calculation of quadrilateral given the
%vertices
ans_area=0.5*abs((p1(1)-p3(1))*(p2(2)-p4(2))-(p2(1)-p4(1))*(p1(2)-p3(2)));
end
_______________________________________________________________________________________________
Output: