% a) Build up a simulation model of a dc-motor(openloop) and test it
L = 0.23 * (10^-3);
cm = 23.4 * (10^-3);
R = 2.4;
J = 0.23 *(10^-6);
D = 0.4191 *(10^-5);
sim('dc_motor_open_loop');
plot(out.tout,out.simout.signals.values);
xlabel('time');
ylabel('roationalspeed');
title('speedcontrol');
% b) 1. dc-motor model with proportional controller value as 1
L = 0.23 * (10^-3);
cm = 23.4 * (10^-3);
R = 2.4;
J = 0.23 *(10^-6);
D = 0.4191 *(10^-5);
sim('dc_motor_closedloop');
plot(out.tout,out.simout.signals.values);
xlabel('time');
ylabel('roationalspeed');
title('speedcontrol');
% b) 1. dc-motor model with proportional controller value as 0.5
L = 0.23 * (10^-3);
cm = 23.4 * (10^-3);
R = 2.4;
J = 0.23 *(10^-6);
D = 0.4191 *(10^-5);
sim('dc_motor_closedloop');
plot(out.tout,out.simout.signals.values);
xlabel('time');
ylabel('roationalspeed');
title('speedcontrol');
% b) 1. dc-motor model with proportional controller value as 0.01
L = 0.23 * (10^-3);
cm = 23.4 * (10^-3);
R = 2.4;
J = 0.23 *(10^-6);
D = 0.4191 *(10^-5);
sim('dc_motor_closedloop');
plot(out.tout,out.simout.signals.values);
xlabel('time');
ylabel('roationalspeed');
title('speedcontrol');
%C) current plot using ODE solver 'ode15s'
L = 0.23 * (10^-3);
cm = 23.4 * (10^-3);
R = 2.4;J = 0.23 *(10^-6);
D = 0.4191 *(10^-5);
sim('dc_motor_open_loop');
plot(out.tout,out.simout.signals.values);
xlabel('time');
ylabel('current');