Species classification by sepal

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
clear

%Load data
load fisheriris
x=meas(:,1:2);
y=categorical(species);
labels = categories(y);
figure(1)
gscatter(x(:,1),x(:,2),species,'rgb','osd');
xlabel('Sepal length');
ylabel('Sepal width');

%Learning by data
classifier{1}=ClassificationDiscriminant.fit(x,y);
classifier{2}=ClassificationTree.fit(x,y);
classifier{3}=ClassificationKNN.fit(x,y);
%classifier{4}=NaiveBayes.fit(x,y); 2019 ver
classifier_name={'Discriminant Analysis','Classification Tree','Nearest Neighbor'}; %'Naive Bayes'

%Check the result
[xx1,xx2]=meshgrid(4:.01:8,2:.01:4.5);
figure(2)
for ii=1:numel(classifier)
ypred=predict(classifier{ii},[xx1(:) xx2(:)]);
h(ii)=subplot(2,2,ii);
gscatter(xx1(:),xx2(:),ypred,'rgb');
title(classifier_name{ii},'FontSize',15)
legend off
axis tight
end

%Confusion Matrix
figure(3)
predictResult=predict(classifier{2},x);
y=categorical(y);
predictResult=categorical(predictResult);
plotconfusion(y,predictResult);
Read more »

Frequency Response

Natural frequency

  • wn = sqrt(k/m)(rad/s) - 회전 주파수
  • fn = wn/(2*pi)(Hz) - 주파수
1
2
3
4
5
6
7
8
>> m=10;
>> b=0.1;
>> k=1000;
>> wn=sqrt(k/m)

wn =

10
Read more »

TF&state-space

1
2
3
4
5
6
7
8
9
10
11
12
syms Y s y(t) t

laplace(10*diff(diff(y(t)))+0.4*diff(y(t))+4*y(t))
Y1=s*Y;
Y2=s*Y1;
sol=solve(10*Y2+0.4*Y1+4*Y-1,Y);
pretty(sol)

num=[1];
den=[10 0.4 4];
h=tf(num, den);
[A,B,C,D]=tf2ss(num, den)
Read more »