Info

This question is closed. Reopen it to edit or answer.

How can I create a 3D matrix with values every 3rd/6th/9th row?

1 view (last 30 days)
How can I make my 3d city have rows every 3rd/6th/9th row?
% Create the height of your buildings
A=rand(11,11)
% Make roads have 0 height
A(3,1:11)=0
A(6,1:11)=0
A(9,1:11)=0
% Make roads have 0 height
A(1,11:3)=0
A(1,11:6)=0
A(1,11:9)=0
  4 Comments
Jan
Jan on 8 Feb 2013
How annoying - another deleting of the question. Sean, the frequent contributor will loose the interest in answering your questions, if you invalidate the threads afterwards. This is a destructive behavior in a public forum.
Randy Souza
Randy Souza on 12 Feb 2013
I have restored the original text of this question.
Sean, this question may be valuable to someone else in the future. If you have a good reason why it should be removed from MATLAB Answers, please flag the question, explain why it should be deleted, and an administrator or high-reputation contributor will consider deleting the question. Please do not simply edit your question away.

Answers (2)

Youssef  Khmou
Youssef Khmou on 7 Feb 2013
Edited: Youssef Khmou on 7 Feb 2013
hi, for the second time ,re-write your question, anyway based on your non organized question, here is what you ask for :
N=11;
a=rand(N);
for i=1:N
if mod(i,3)==0
a(i,:)=0;
end
end
But this is not what you wanted, you wanted when surfing the matrix a , to see "parallelepipeds" as buildings , you repost the question with proper description .

Youssef  Khmou
Youssef Khmou on 12 Feb 2013
clc,
close all
N=11;
a=rand(N);
for i=1:N
if mod(i,3)==0
a(i,:)=0;
a(:,i)=0;
end
end
fprintf(' Original city :\n');
a
figure, surf(a), colormap gray, view(-36,86), axis off
fprintf('\n after years of civilization , the city became :\n')
building=ones(20);
b=kron(a,building);
b(1,:)=0;
b(:,1)=0;
b(end,:)=0;
b(:,end)=0;
figure, surf(b,'AmbientStrength',0.85), xlabel(' Streets');
ylabel(' Streets'), title(' Sean''s CITY'), axis off,view(93,4)

Tags

Community Treasure Hunt

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

Start Hunting!