



























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
It contains solved examples of matlab codes as well as maths textbook notes helpful for ug calculus
Typology: Assignments
1 / 67
This page cannot be seen from the preview
Don't miss anything!




























































OUTPUT: rv = 1 2 3 4 5 sv = 15 rvt = 1 2 3 4 5 cv1 = 1 2 3 4 5 cv2 = 1 2 3 4 5 A = 1 2 3 4
dA =
E = -2.0000 1. 1.5000 -0. rA = 2 lA = 1 0 3 4 uA = 1 2 0 4 B = 4 5 8 12 C = 5 7 11 16 D1 = 20 29 44 63 D2 = 4 10 24 48
2 1 14 13 x = 1 2 3 y = 4 5 6 dp = 32 cp = -3 6 - x1 = 0 1 2 3 4 5 x2 = 0 1 2 3 4 5 x3 = 0 2 4 6 x4 = 0 2 4 6
Problem Statement: Define f(x)=x^3 directly Code: clc clear all syms x f=x^ v3=subs(f,x,3) x0=1:5; v4=subs(f,x,x0) OUTPUT: f = x^ v3 = 27 v4 = [1, 8, 27, 64, 125]
Problem Statement: Define f(x)=x^3 using anonymous function (without any named identifier) Code: clc clear all f=@(x) (x.^3); v5=f(3) x0=1:5; v6=f(x0) OUTPUT: v5 = 27 v6 = 1 8 27 64 125 Problem Statement %(iv) Define f(x,y)=x^2+y^2 using anonymous function Code clc clear all f=@(x,y) (x.^2+y.^2); v7=f(1,2) x0=[1 2 3]; y0=[4 5 6]; v8=f(x0,y0)
v7 = 5 v8 =
f=x^2+y^2; end function [g] = udfname2(x,y,z) g=x^2+y^2+z^2; end Output fpt = 5 fpts = [26, 40, 58, 80] gpt = 14 Problem statement % Solving system of linear equations, say, 4x+5y=7,7x+8y= CODE: clc clear all A=[4 5;7 8] b=[7 21]' x=A\b Output A = 4 5 7 8 b = 7
21 x =
-11.
Problem statement: %2.Multiple plots in a Figure window (using command hold on) CODE: clc clear all x=linspace(0,2pi,50); plot(x,sin(x),'r') hold on plot(x,cos(x),'g.') plot(x,cos(2x),'b-+') legend('sin(x)','cos(x)','cos(2x)') OUTPUT:
Problem statement: %3.Multiple plots in a Figure window (without command hold on) CODE: clc clear all x=linspace(0,2pi,50); plot(x,sin(x),'r',x,cos(x),'g-.',x,cos(2x),'b-+') legend('sin(x)','cos(x)','cos(2x)') OUTPUT:
Problem Statement: %5.Graph of a curve through ezplot command CODE: clc clear all syms x f=sin(2x)+cos(3x); % default domain {for sin, cos [-2pi.2pi]} D=[0 pi]; ezplot(f,D) OUTPUT:
Problem statement: %6.Plot a curve in space CODE: clc clear all t=linspace(0,2pi,50); x=cos(t);y=sin(t);z=sin(5t); plot3(x,y,z,'b.-','markersize',7) xlabel('x-axis') ylabel('y-axis') zlabel('z-axis') title('Curve in space') OUTPUT: