Generating A Step Like Function In MATLAB.

4 views (last 30 days)
Hi, Previous suggestion to my question was alright. That was much useful to generate a step like function using the command"stairs". But I need to do it without using the standard in-built functions. So, can anyone please help me in generating a stair like function using for loops(or something like that) whose increment and decrement should be by same amount and rises upto a certain height,in MATLAB.
Thanking You!

Accepted Answer

Titus Edelhofer
Titus Edelhofer on 6 Jan 2012
Hi,
in this case I would take a look at the output of stairs, e.g.
[x,y]=stairs(1:3, 2:0.5:3)
x =
1
2
2
3
3
y =
2.0000
2.0000
2.5000
2.5000
3.0000
and try to achieve the same using "pure" MATLAB code ...
Titus
  2 Comments
Pranjal Pathak
Pranjal Pathak on 6 Jan 2012
Sir, Thanks for your answers. Now can you help me in finding the slopes of this step function IN matlab?
Titus Edelhofer
Titus Edelhofer on 6 Jan 2012
The slope is the ratio by how fast the y values grow devided by how fast the x values grow. If you plot the stairs above (e.g. call stairs without "[x,y]=", followed by "axis equal" you will see, that those stairs have a slope of 0.5 ...
Titus

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!