Professional Documents
Culture Documents
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)
x = linspace(0,1,101)
plot(x,x.^3,'r+',x,sin(x),'b-',x,exp(x),'g.')
A=[4 5;7 8]
b=[7 21]'
x=A\b
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)