% --------------------------- clearvars x = [0:5:100]; y = x; plot(x, y) % --------------------------- % --------------------------- clearvars year = 1956:10:2016 pop = [ 18954 25785 33708 49445 60055 70495 80043 ] plot(year,pop, '--bs'); title('Iran population'); % --------------------------- % --------------------------- clearvars x = [-100:20:100]; y = x.^2; plot(x, y) % --------------------------- % --------------------------- clearvars x = [-100:5:100]; y = x.^2; plot(x, y) % --------------------------- % --------------------------- clearvars x = [0:0.01:10]; y = sin(x); plot(x, y), xlabel('x'), ylabel('Sin(x)'), title('Sin(x) Graph'),grid on, axis equal % --------------------------- % --------------------------- clearvars x = [0 : 0.01: 10]; y = sin(x); g = cos(x); plot(x, y, x, g, '.-'), legend('Sin(x)', 'Cos(x)'); % --------------------------- % --------------------------- clearvars x = [-10 : 0.01: 10]; y = 3*x.^4 + 2 * x.^3 + 7 * x.^2 + 2 * x + 9; g = 5 * x.^3 + 9 * x + 2; plot(x, y, 'r', x, g, 'g') % --------------------------- % --------------------------- clearvars x = [0 : 0.01: 10]; y = exp(-x).* sin(2*x + 3); plot(x, y), axis([0 10 -1 1]); % --------------------------- % --------------------------- clearvars x = [0:0.01:5]; y = exp(-1.5*x).*sin(10*x); subplot(1,2,1) plot(x,y), xlabel('x'),ylabel('exp(–1.5x)*sin(10x)'),axis([0 5 -1 1]) y = exp(-2*x).*sin(10*x); subplot(1,2,2) plot(x,y),xlabel('x'),ylabel('exp(–2x)*sin(10x)'),axis([0 5 -1 1]) % --------------------------- % --------------------------- clearvars x = linspace(0,2*pi); y = sin(x); plot(x,y,'-o') axis([0 2*pi -1.5 1.5]) % --------------------------- % --------------------------- clearvars figure Y = linspace(-2*pi,2*pi,50); stem(Y) % --------------------------- % --------------------------- doc LineSpec % --------------------------- % --------------------------- clearvars x= -4:0.5:4; y= x.^2; subplot(2,2,1) plot(x,y,'-r','LineWidth',3) subplot(2,2,2) plot(x,y,'-rx','LineWidth',1) subplot(2,2,3) plot(x,y,'-rs','LineWidth',1, 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'k') subplot(2,2,4) plot(x,y,'-rs','LineWidth',1, 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'k', 'MarkerSize', 10) % --------------------------- % --------------------------- clearvars x = linspace(-4,4); y = x.^2; plot(x,y) grid on set(gca, 'XTick', -4:2:4) set(gca, 'YTick', 0:1:16) legend('babak'); % --------------------------- % --------------------------- clearvars x = linspace(-2,2); y1= x.^2; y2= 2*sin(x); plot(x, y1, '--r',x, y2, 'o'); text(0,0.5,'babak'); % --------------------------- % --------------------------- clearvars x=[-3:1:3]; y=[-3:1:2]; [xx,yy]=meshgrid(x,y); zz=xx.^2-yy.^2; figure; surf(xx,yy,zz); shading interp % --------------------------- % --------------------------- ezsurf('real(atan(x+i*y))') % --------------------------- %---------------------------- surf surfc surfl mesh meshz %---------------------------- %---------------------------- clearvars z = peaks(25); figure mesh(z) surf(z) colormap(jet) surfl(z) colormap(pink) shading interp contour(z,16) colormap default %---------------------------- %---------------------------- clearvars t = 0:pi/50:10*pi; st = sin(t); ct = cos(t); figure plot3(st,ct,t) %---------------------------- %---------------------------- clearvars [X,Y] = meshgrid(1:0.5:10,1:20); Z = sin(X) + cos(Y); C = X.*Y; surf(X,Y,Z,C) colorbar %---------------------------- %---------------------------- [X,Y]=meshgrid(-8:0.5:8); R = sqrt(X.^2+Y.^2) + eps; Z = sin(R)./R; surf(X,Y,Z) %----------------------------