How to plot the graph of Greatest Integer Function ?

I was trying to plot greatest integer function by using floor command and stem (to show discontinuity) but what i am getting is,please help me out!!!
I used the code
x=linspace(1,10,10) y=floor(x); stem(x,y)

2 Comments

What did you expect to see?
This is close, I got this using the code below:
Dots are right, lines are going wrong way.
Code:
syms y
>> y=floor(x); x=linspace(1,10,10); stem(x,y)

Sign in to comment.

Answers (4)

x=linspace(1,10,10)
y=floor(x) % ARE THESE VALUES AS EXPECTED??
stairs(x,y) % rather than stem

1 Comment

Sorry brother,but this is showing a continuous graph whereas the greatest integer function is a discontinuous function,sorry but this plot is wrong

Sign in to comment.

Sorry brother,but this is showing a continuous graph whereas the greatest integer function is a discontinuous function,sorry but this plot is wrong

Asked:

on 8 Jun 2016

Answered:

on 10 Oct 2023

Community Treasure Hunt

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

Start Hunting!