CE122 Lab2
CE122 Lab2
• Write a MATLAB script to plot the function y = x2, {x: -10 ≤ x ≤ 10}.
• Add labels and a title to the plot.
• Create a new figure
• Use the hold on keyword to create a 2 on 1 plot of 2graphs: one for y = sin(x) and
another for y = cos(x).
• Add labels, title, and a legend to the plot
• Use the subplot function to create a 2x1 grid of plots: one for y = sin(x) and another for
y = cos(x) on another figure.
• Add labels and titles to the plot.
• Write a script to prompt the user separately for a character and a number.
• Print the character in a field width of 3 and the number left justified in a field width of 8
with 3 decimal places.
• What is the disp?
4) Functions
• Write an anonymous function in MATLAB that takes a number as input and returns its
square.
• Create a function file to calculate the area of a circle given the radius.