On Matlab, Draw a small cityscape that is built from an 11 × 11 matrix where the
ID: 2079601 • Letter: O
Question
On Matlab, Draw a small cityscape that is built from an 11 × 11 matrix where the values in the matrix are the building’s heights. Assume a city block is 2x2 with a building in each cell (so each block has 4 buildings). Be sure each block has a street on each interior side. Use the default colormap. Utilize the bar3 function to get your buildings. Hint: You can specify each cell manually using A(1, 1) = 50, A(1, 2) = 75, etc, or you can get creative by using a scaled randi function to set the height...just remember the streets will need to eventually be set to zero.
Explanation / Answer
for n=1:1:11
for m=1:1:11
y(m,n)=randi(100);
if mod(m,2)==0
y(m,n)=0;
end
if mod(n,2)==0
y(m,n)=0;
end
end
end
width=0.5
bar3(y,width);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.