Using Matlab, plot the function f(x) = x^2 on the domain [0, 1], letting delta x
ID: 3027644 • Letter: U
Question
Using Matlab, plot the function f(x) = x^2 on the domain [0, 1], letting delta x = 0.1 and delta x = 0.01. This means that your x domain (vector) should increase from 0 to 1 in increments of 0.1 and then 0.01. Your y domain (vector) will be the corresponding values, f(x). Plot both functions in one window with the help of the command hold on. Note that the two graphs should essentially lie on top of each other. (For this problem, you should submit both the commands used - screenshot or copy/paste from the Matlab command line- and your plot.)Explanation / Answer
Here is the matlab script for your question
%% MATLAB Script starts here
x_1 = 0:0.1:1;
x_2 = 0:0.01:1;
y_1 = x_1.^2;
y_2 = x_2.^2;
figure;plot(x_1,y_1);
hold on;
plot(x_2,y_2);
%% MATLAB script ends here