Exercise
Exercise
2
Problem 1: Equation of a Straight Line
Q: Compute y = mx + c for given x values, with m = 0.5 and c = -2.
A:
Problem 3: Points on a Circle
Q: Verify that points (x, y) lie on a circle of radius r = 2.
A:
A:
Problem 5: Matrix and Vector Manipulation
Q: Create a vector and a matrix, extract and display first 10 elements as column vectors.
A:
EXERCISE 2.3
Question: Plot the same sine wave along with its unconnected data points represented by circles.
3. Exponentially Decaying Sine Plot
Question: Plot the function y = e^(-0.4x) * sin(x) using 10, 50, and 100 points and observe the difference.
5. On-Line Help
Question: Use the MATLAB command window to access help for the plot function.
Question: Use semilogx, semilogy, and loglog to plot y = x^3 with x = 0:10:1000.
7. Overlay Plots
Question: Plot y = cos(x) and its fourth-order Taylor approximation on the same graph for 0 ≤ x ≤ π.
8. Fancy 2D Plot
clc;
clear;
% Run your script or calculations
% Check current variables in the workspace
who
% Get detailed information about the variables
whos
% Display the values of theta, x, and y
[theta' x' y']
1. Help on function
3.
3.Factorial with Input Validation