xvals = -2:0.04:2; fvals = sin(xvals) + 2*exp(-30*(xvals.^2)); fsd = std(fvals); epssd = fsd/5; eps = normrnd(0, epssd, 1, 101); yvals = fvals + eps; plot(xvals, fvals, '-k', 'LineWidth', 2) hold on; plot(xvals, yvals, '.k', 'MarkerSize', 15) line([1.4, 1.4], [-2, 3], 'LineStyle', '--', 'Color', 'k', 'LineWidth', 2) line([1.6, 1.6], [-2, 3], 'LineStyle', '--', 'Color', 'k', 'LineWidth', 2) set(gca, 'FontSize', 22, 'XLim', [-2.1, 2.1], 'YLim', [-1.5, 2.3], 'XTick', -2:1:2, 'YTick', -1:1:2, 'TickDir', 'out', 'Box', 'off') xlabel({'';'x'}, 'FontSize', 22) ylabel({'y';''}, 'FontSize', 22) set(gcf, 'Position', [200, 100, 1000, 800])