I need to work out the area of all residential areas. I tried using polyarea but cant get it to work.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
The code all works appart from the last 3 (talking about area.) I tried using polyarea but error comes up saying too many input arguements.
RoomTotalResidential =0;
for c = 1:1:sBuilding(n).bNoOfFloors
disp("--------------FLOOR "+c+" --------------")
subplot(sBuilding(n).bNoOfFloors,1,c);
title(sprintf('Floor %d',c));
sFloor(c).NoOfResidentialSpaces = input('Enter Number Of Residential spaces:');
FloorTotalResidential = sFloor(c).NoOfResidentialSpaces;
RoomTotalResidential = RoomTotalResidential + FloorTotalResidential;
if sFloor(c).NoOfResidentialSpaces > 0
for i = 1:1:sFloor(c).NoOfResidentialSpaces
sFloor(c).resident(i).width = input("Enter width of Residential room " +i+" on floor "+c+":");
sFloor(c).resident(i).length = input("Enter length of Residential room "+i+" on floor "+c+":");
choice1 = questdlg('Would you like to draw a floorplan?','question','yes','no','yes');
switch choice1
case 'no'
disp('No floorplan')
case 'yes'
locationx=input("Please specify bottom left corner X coordinate of residential room "+i+" on floor "+c+":");
locationy=input("Please specify bottom left corner Y coordinate of residential room "+i+" on floor "+c+":");
rectangle('Position',[locationx locationy sFloor(c).resident(i).width sFloor(c).resident(i).length]);
axis ([0 100 0 100]);
hold on
area = polyarea(locationx,locationy,sFloor(c).resident(i).width,sFloor(c).resident(i).length);
disp('The area is:'+area);
end
end
end
2 comentarios
Walter Roberson
el 3 de Mayo de 2022
area = sFloor(c).resident(i).width * sFloor(c).resident(i).length
polyarea() is not going to be to your advantage unless you have more complicated shapes.
Respuestas (0)
Ver también
Categorías
Más información sobre Computational Geometry en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!