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

4 Ansichten (letzte 30 Tage)
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!

Akzeptierte Antwort

Joseph Cheng
Joseph Cheng am 12 Jun. 2015
Bearbeitet: Joseph Cheng am 12 Jun. 2015
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 Kommentar
Image Analyst
Image Analyst am 21 Jun. 2015
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 :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by