You are on page 1of 2

clc

clear all

% 1. Matrix operations
A=[1 2;3 4];
B=[4 5;8 12];
C=A+B
D=A*B
E=inv(A)
F=B'
% H=A.^2
I= det(A)

%2.Circle with centre(1,3)


t = linspace(0, 2*pi);
x = 1 +2*cos(t);
y = 3 +2*sin(t);
plot(x,y)
axis equal

%3.plotting three functions without hold on

x = linspace(0,1,101)
plot(x,x.^3,'r+',x,sin(x),'b-',x,exp(x),'g.')

%4. Solving system of linear equations, say, 4x+5y=7,7x+8y=21


% In general,
%X = A\B solves for X in A*X = B and
% X = B/A solves for X in X*A = B.

A=[4 5;7 8]
b=[7 21]'
x=A\b

%5.solving quadratic equations

syms ('x')
solve(2*x^2+5*x+12)
%6.ezplotting
syms x
f=sin(2*x)+cos(3*x)
ezplot(f)

%7.subplot
x=0:.1:2*pi;
subplot(2,2,1);
plot(x,sin(x));
subplot(2,2,2);
plot(x,cos(x));
subplot(2,2,3)
plot(x,exp(-x));
subplot(2,2,4);

%8.symbolic differentiation

syms x y
f =x^2+2*x*y+y*sin(x)
diff(f,x)
diff(f,y)

%9.Symbolic integration
syms x
f=x^3+3*x^2+5*x+12
int(f,x,0,2)

You might also like