create a graph with a specific interval

1 view (last 30 days)
Milo Llimo
Milo Llimo on 1 Dec 2021
Commented: Jon on 1 Dec 2021
  2 Comments
Milo Llimo
Milo Llimo on 1 Dec 2021
n=0:35
x1=sin((pi/17)*n);
stem(x1)
axis([0 35 -1.5 1.5])
grid on
my problem is in n values are not correct, 35 must be not included

Sign in to comment.

Answers (1)

Jon
Jon on 1 Dec 2021
If you want n to have integer values greater than zero and strictly less than 35 you can define
n = 0:34
If you don't require the values to be integers but just want them equally spaced up to some value slightly less than 35 you could use
tol = 1e-6; % amount less than 35 that you want to reach
nMax = 35 - tol; % final value for n
numPoints = 100; % number of equally space points that you want
n = linspace(0,nMax,numPoints)
  2 Comments
Jon
Jon on 1 Dec 2021
Are you all set now? If this answered your question please Accept the answer so others will know an answer is available.

Sign in to comment.

Tags

Products

Community Treasure Hunt

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

Start Hunting!