• Remix
  • Share
  • New Entry

on 10 Oct 2021
  • 28
  • 120
  • 0
  • 0
  • 276
axes('View',[155 30],'Color','k')
hold
Current plot held
h=randg(1,22); % building heights
b=bar3(h);
axis equal
g=.16; % height and width of windows
[m,k]=ndgrid(1:22); % (x,y) building indices
for i=1:484 % loop through each building
% Interpolate building color according to building height
% Ideally this should be outside the loop but that would require more characters
q=b(m(i));
set(q,'CData',q.ZData,'FaceC','i')
for j=1:2 % loop through each column of windows
L=k(i)-.3+(j-1)*.4; % in k-a+(j-1)*b, a is the signed distance from center of building in row k(i) to left edge of window in column j and b is the interval between left edges of windows.
x=L+[0,g,g,0]'; % [L;R;R;L] edges of windows in building i, window column j
z=ones(4,1)*(.2:.4:h(i)-.2)+[0;0;g;g]; % 4xn height of windows for n levels of windows; in a:b:c a is height of first row of windows, b is the interval between window-bottoms, c is height of tallest window.
y=z*0+m(i)+.4; % 4xn location of front face of building
% Plot windows for building i, column j
patch(z*0+x,y,z,'y')
end
end
camva(3)
light
%camlight(99,80)
Remix Tree