draw the graph of y=x2 for -10<x<10 and compute y(3). in matlab

main.m
x = -10:0.1:10;
y = x.^2;

plot(x, y);
xlabel('x');
ylabel('y');
title('Graph of y = x^2');
grid on;

% Computing y(3)
index = find(x == 3);
y_at_3 = y(index);
disp(['y(3) = ', num2str(y_at_3)]);
196 chars
14 lines

related categories

gistlibby LogSnag