MatLab: how to create a rectangular hole in a hyperbolic paraboloid

조회 수: 5 (최근 30일)
Hi all, i'm new in the world of MatLab and for a course at the University i've decided to draw a building with the software. The building is West 57 by BIG in Manhattan. It's a parallelepiped with a big hyperbolic paraboloid above. So now i have found the equation of the hyperbolic paraboloid and also i have drawn the parallelepipid on the base. The problem is that i really don't know how to create the rectangular hole, i know where it has to be, but how can i write it down in MatLab? The code for the hyperbolic paraboloid is:
[s,t]=meshgrid(linspace(0,1,20),linspace(0,1,20));
[X,Y,Z]=meshgrid(0:1:60,0:1:150,0:1:130);
X=(150*s);
Y=(60*t);
Z=((8+(X.*(Y)))-(8870*(s.*t)));
axis tight;
axis equal;
surf(X,Y,Z)
This is the building
and this is the result i've reached in MatLab
The hole is missing xD. Please someone help me :) Thank you for your attention!

채택된 답변

Joseph Cheng
Joseph Cheng 2015년 6월 12일
편집: Joseph Cheng 2015년 6월 12일
just create a mask or by change the hole into NaN
[s,t]=meshgrid(linspace(0,1,20),linspace(0,1,20));
[X,Y,Z]=meshgrid(0:1:60,0:1:150,0:1:130);
X=(150*s);
Y=(60*t);
Z=((8+(X.*(Y)))-(8870*(s.*t)));
axis tight;
axis equal;
figure(1),subplot(1,3,1),surf(X,Y,Z)
%generate mask
x = X>=25 & X<=125;
y = Y>=20 & Y<=40;
hole = double(~(x&y));
hole(hole==0)=nan;
subplot(1,3,2),surf(X,Y,Z.*hole)
%or do it all together
Z(X>=25 & X<=125 & Y>=20 & Y<=40)=nan;
subplot(1,3,3),surf(X,Y,Z)
  댓글 수: 1
Image Analyst
Image Analyst 2015년 6월 21일
Marco's "Answer" moved here since it's not an answer:
Ohhh thank you very much :) i've got a last question, now ho can i close the hole with 4 surfaces in that exact space? For the biggest surface for example i have tried this code:
[u,v]=meshgrid(linspace(25,125,20),linspace(0,130,20));
w=meshgrid(linspace(40,40,20));
x=u;
y=w;
z=(8+((u.*v)-(16120*(s.*t))));
surf(x,y,z)
but it doesn't work and i don't understand why :(
thank you for the attention :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by