Viewing a house in MATLAB
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi, I would like to view the house given in the mat file.
When I issue:
load husdata.mat
patch(walls{1,1},walls{1,2},walls{1,3},'r')
set(gca,'projection','perspective')
view(3)
axis('off')
I get this
however, I think it should be a complete house, where one sees the roof. How can I view the whole thing and change the color of the roof into grey?
Thanks!
댓글 수: 0
채택된 답변
Star Strider
2024년 2월 29일
The walls and roof needed duplicates with some offsets to plot correctly. Other than that, the patch arguments are set up to be straightforward to plot (for which I am grateful, because 3D patch plots can sometimes be challenging). I coloured the walls differently to show their differences when viewed at different angles. Colour them as you prefer. In the second plot, I changed the roof colour to gray.
Try this —
load('husdata.mat')
% whos
R = roof;
W = walls;
figure
hold on
patch(W{1,1}, W{1,2}, W{1,3}, 'r')
patch(W{2,1}, W{2,2}, W{2,3}, 'g')
patch(W{1,1}, W{1,2}+9, W{1,3}, 'c')
patch(W{2,1}+6, W{2,2}, W{2,3}, 'm')
patch(R{1}, R{2}, R{3}, 'b')
patch(flip(R{1})+3.3, R{2}, R{3}, 'b')
hold off
xlabel('X')
ylabel('Y')
view(30,30)
title('House: Front View (Note: X & Y Coordinates)')
figure
hold on
patch(W{1,1}, W{1,2}, W{1,3}, 'r') % End Wall
patch(W{2,1}, W{2,2}, W{2,3}, 'g') % Side Wall
patch(W{1,1}, W{1,2}+9, W{1,3}, 'c') % End Wall
patch(W{2,1}+6, W{2,2}, W{2,3}, 'm') % Side Wall
patch(R{1}, R{2}, R{3}, [1 1 1]*0.5)
patch(flip(R{1})+3.3, R{2}, R{3}, [1 1 1]*0.5)
hold off
xlabel('X')
ylabel('Y')
view(210,30)
title('House: Rear View (Note: X & Y Coordinates)')
.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!