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 ?
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).


Comments
Post a Comment