How to use stairs (or another function) to create stairs in a 3d space
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Johnny Dessoulavy
am 3 Okt. 2021
Bearbeitet: Matt J
am 4 Okt. 2021
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.
0 Kommentare
Akzeptierte Antwort
Matt J
am 4 Okt. 2021
Bearbeitet: Matt J
am 4 Okt. 2021
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'
Weitere Antworten (1)
Matt J
am 3 Okt. 2021
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 Kommentar
Siehe auch
Kategorien
Mehr zu Title finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!