Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
9 views1 page

A1 Practical 1

Uploaded by

abhisekn38
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

A1 Practical 1

Uploaded by

abhisekn38
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Assignment 1

QUESTION 1 Plotting Basic Trigonometric and Exponential Functions


1. Create a vector x from –2π to 2π with 800 points.
2. Compute and plot on one figure:
• y₁ = sin(x) using a solid red line
• y₂ = cos(0.5·x) using a dashed blue line
3. On the same axes, plot y₃ = exp(–0.1·x.^2) with a thick green line.
4. Add grid, legend entries (“sin(x)”, “cos(0.5 x)”, “exp(–0.1 x²)”), xlabel “x”, ylabel “y”, and
title “Trigonometric & Exponential”.
5. Save your code as Q1_trig_exp.m
QUESTION 2
Subplots of Polynomial, Logarithmic, and Absolute-Value Functions
1. Define x = linspace(0,10,500).
2. Compute:
• p = x.^3 – 6·x.^2 + 4·x + 12
• l = log(x + 1)
• a = abs(x – 5)
3. Create a 3×1 subplot layout:
• Plot p in magenta, line width 1.5, title “Polynomial p(x)”
• Plot l in cyan with circle markers (o), title “Logarithm l(x)”
• Plot a using a stem plot in black, title “Absolute Value a(x)”
4. Label each subplot’s axes and enable grid.
5. Save your code as Q2_subplots.m
QUESTION 3
Parametric and Polar Plots
1. Generate parameter t from 0 to 4π with 400 points.
2. Define two parametric curves:
• Circle: xc = 2·cos(t); yc = 2·sin(t)
• Spiral: xs = t.*cos(t); ys = t.*sin(t)
Plot both on one figure using distinct colors and line styles.
3. Use axis equal, add legend (“Circle”, “Spiral”), enable grid, and title “Parametric Curves”.
4. In a new figure, create a polar plot of r = 1 + 0.5·sin(5·θ) for θ from 0 to 2π. Title it “Polar
Rose”.
5. Save your code as Q3_param_polar.m

You might also like