matlab - how i can plot a graph with inetger number as input -


how can plot cos(3 pi/7 * n ) such n integer number in interval [x=0,x=10] in matlab? used code

figure x = linspace(0,2*pi,10)'; y = cos(x); stem(x,y) set(gca,'xlim',[0,10])  

the graph , want show points of graph in integer number of x axis . how can ?

enter image description here

instead of using linspace such simple example one, can define vector x integer vector taking steps of 1, 0 10:

figure x = 0:1:10; y = cos(3*pi/7*x); stem(x,y) set(gca,'xlim',[0,10])  

below shows plot generated code snippet above (bottom plot) same plot using step size 0.5 (x = 0:0.5:10, top plot).

note adriaan notes in comments below, default step size ... = from:stepsize:to notation 1, i.e., if omitting stepsize , writing ... = from:to, step size of 1 used default (stepsize=1).

enter image description here


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -