필터 지우기
필터 지우기

How to use stairs (or another function) to create stairs in a 3d space

조회 수: 26 (최근 30일)
Im trying to create a matrix of z values that will correspond to stairs. The aim is to be able to input any x-size and y-size vector values and have a z matrix which is an inclined plane, with a set of stairs travelling its height.
I have tried to ahrd code this, but im not getting evry far at all. I have tried searching online, but there doesnt seem to be reference to using stairs or similar to achieve what I want.
If someone could help me out, or point me in the direction or resources/solution i would be very grateful.

채택된 답변

Matt J
Matt J 2021년 10월 4일
편집: Matt J 2021년 10월 4일
Here's another method using repelem. IMO, it is a bit more transparent way to achieve a desired staircase geometry. You can use imrotate() to change the direction of the steps.
h=12;
stepHeight=3;
stepLength=50;
stepWidth=10;
z=0:stepHeight:h;
Z=repelem(z,stepWidth,stepLength);
[m,n]=size(Z);
x=linspace(0,10,n);
y=linspace(0,8,m);
surf(x,y,Z)
xlabel 'X', ylabel 'Y'

추가 답변 (1개)

Matt J
Matt J 2021년 10월 3일
Something like this, perhaps?
x=linspace(1,3);
y=x.';
z=round(3*x +2*y);
surf(x,y,z,'EdgeColor','none')
view(30,20);
  댓글 수: 1
Johnny Dessoulavy
Johnny Dessoulavy 2021년 10월 4일
편집: Johnny Dessoulavy 2021년 10월 4일
Yes! something like that exactly. I need it to travel in a straight line rather than horizontally, like you have. for example it goes from 0 x to 10x, y being the depth of each step so, for arguments sake, a depth of 2, and then finally end at a prescribed z height, h.
So, what you have is perfect but needs to be translated 45degrees, if you understand where im going.
for reference, this is what i have right now.
The steps need to ascend up the inclined plane. Im wanting to be able to have as many rows and columns as i want, but have a proportional amount of steps IE 100 rows and 50 columns, but that results to like 10 steps up the inclined plane. Your steps are what im looking for, but need to be applied slightly differently.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Title에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by