clear clf np = 20; x = linspace(-1, 1, np); f = zeros(np, 1); for i = 1:np f(i) = example(x(i)); end plot(x, f, 'o-') grid on title('Graph of a function that uses conditionals') xlabel('x') ylabel('y(x)') function y = example(x) if x > 0 y = x; else y = x^2; end end