MATLAB (2)

Bar Plots

1
2
3
x = -2.9:0.2:2.9;
y = exp(-x.*x);
bar(x,y)

Stairstep Plots

1
2
3
x = 0:0.25:10;
y = sin(x);
stairs(x, y)

Errorbar Plots

1
2
3
4
x = -2:0.1:2;
y = erf(x);
eb = rand(size(x))/7;
errorbar(x,y,eb)

Polar Plots

1
2
3
theta = 0:0.01:2*pi; %angle
rho = abs(sin(2*theta).*cos(2*theta)); %radius
polarplot(theta,rho)

Stem plots

1
2
3
x = 0:0.1:4;
y = sin(x.^2).*exp(-x);
stem(x,y)

Scatter plots

1
2
3
4
load patients Height Weight Systolic %load data
scatter(Height,Weight) %scatter plot of Weight vs. Height
xlabel('Height')
ylabel('Weight')

부분분수 전개

1
2
3
b=[-4 8]; %분자
a=[1 6 8]; %분모
[r,p,k]=residue(b,a)
1
2
3
4
r=[-12 8];
p=[-4 -2];
k=[];
[b,a] = residue(r,p,k) %역변환

ODE

1
2
3
x=sym('x');
U1=diff((2*x^2-x)^3);
U2=diff((x/(x+1))^2);

Solutions of ODE

1
2
syms x y;
U=dsolve('D2y+2*Dy+3*y=0','y(0)=1','Dy(0)=1','x')