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

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

hi, i suggest that you change the title of your question, and make it a bit professional even for numerical drawing, so as to get responses from professionals .
Then change the body so that people can understand what you want to do. For example, what does "have rows every 3rd/6th/9th row" mean???? Evidently from your code you meant "have zeros every 3rd row". Did you proofread your question before you posted it?
Finally learn to format your code. Highlight your code, then click the {}Code icon above the text box.
By the way, your new subject line "3D model I ling" makes as little sense as your last one. What is a "ling"?
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.
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)

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 .
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)

This question is closed.

Tags

Asked:

on 6 Feb 2013

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!