%% BLDC Motor
clear all
clc

% Initialisierung
Uz = 11.7;      %Akkuspannung in V
R = 0.0016;     %Strangwiderstand in Ohm
L = 30*10^-6;   %Straninduktivität in Henry
kf = 0.02;      %Motorkonstante in
p = 4;          %Pole
J = 0.005;      %Trägheitsmoment
ke = 0.02;      %

% State Space
A = [-R/L,  0,   0,    0; 
       0, -R/L,  0,    0; 
       0,   0, -kf/J,  0; 
       0,   0,   p/2 , 0]

B = [2/(3*L), 1/(3*L),   0;
    -1/(3*L), 1/(3*L),   0;
       0,        0,     1/J;
       0,        0,      0]

C = [1, 0, 0, 0;
     0, 1, 0, 0;
    -1,-1, 0, 0;
     0, 0, 1, 0;
     0, 0, 0, 1]
 
 D = [0, 0, 0;
     0, 0, 0;
     0, 0, 0;
     0, 0, 0;
     0,0,0]
 
 %% Plot
 
 plot (w_mech.time , w_mech.signals.values)