You are on page 1of 8

% AC motor parameters

M = 0.01; % Rotor moment of inertia (kg.m^2)


f = 0.1; % Friction constant (N.m.s)
Ke_ac = 0.01; % Electromotive force (V/rad/sec)
Kt_ac = 0.01; % Motor torque coefficient (N.m/A)
R_ac = 1; % Resistance (Ohm)
L_ac = 0.5; % Inductance (H)

Mtrx_A = [0 1 0; 0 -f/M Kt_ac/M; 0 -Ke_ac/L_ac -R_ac/L_ac];


Mtrx_B = [0; 0; 1/L_ac];
Mtrx_C = [1 0 0];
Mtrx_D = 0;

% State-space
ss_system = ss(Mtrx_A, Mtrx_B, Mtrx_C, Mtrx_D);

poles_system = eig(Mtrx_A);

% 1. Gain
gain_AC = Mtrx_C * inv(-Mtrx_A) * Mtrx_B + Mtrx_D;

Warning: Matrix is singular to working precision.

% 2. Natural Frequency, Damping Ratio


[numerator, denominator] = ss2tf(Mtrx_A, Mtrx_B, Mtrx_C, Mtrx_D);
damping_info = damp(tf(numerator, denominator));

% 3. Zeros and Poles


zeros_system = tzero(ss_system);

% 4. Characteristics: Settling Time, Rise Time, Overshoot Percentage


step_information = stepinfo(ss_system);

% 5. Frequency Response (Bode plot)


freq = logspace(-1, 2, 100);
[magnitude, phase_angle] = bode(ss_system, freq);

figure;
subplot(2, 1, 1);
semilogx(freq, 20*log10(magnitude(:)));
title('Frequency Response - Magnitude');
xlabel('Frequency (rad/sec)');
ylabel('Magnitude (dB)');
grid on;

subplot(2, 1, 2);

1
semilogx(freq, phase_angle(:));
title('Frequency Response - Phase');
xlabel('Frequency (rad/sec)');
ylabel('Phase (degrees)');
grid on;

% 6. Impulse Reaction
time_impulse = 0:0.01:5;
impulse_reaction = impulse(ss_system, time_impulse);
figure;
plot(time_impulse, impulse_reaction);
title('Impulse Reaction');
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;

2
% 7. Step Reaction
time_step = 0:0.01:5;
step_reaction = step(ss_system, time_step);
figure;
plot(time_step, step_reaction);
title('Step Reaction');
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;

3
% 8. Ramp Reaction
time_ramp = 0:0.01:5;
ramp_reaction = lsim(ss_system, time_ramp, time_ramp);
figure;
plot(time_ramp, ramp_reaction);
title('Ramp Reaction');
xlabel('Time (seconds)');
ylabel('Amplitude');
grid on;

4
% Information Display
disp('Machine Properties:');

Machine Properties:

disp(['System Matrix A:']);

System Matrix A:

disp(Mtrx_A);

0 1.0000 0
0 -10.0000 1.0000
0 -0.0200 -2.0000

disp(['Input Matrix B:']);

Input Matrix B:

disp(Mtrx_B);

0
0
2

disp(['Output Matrix C:']);

Output Matrix C:

5
disp(Mtrx_C);

1 0 0

disp(['Direct Transmission Matrix D:']);

Direct Transmission Matrix D:

disp(Mtrx_D);

disp(['Eigenvalues (Poles):']);

Eigenvalues (Poles):

disp(poles_system);

0
-9.9975
-2.0025

% 1. Gain Analysis
disp(['Gain Analysis:']);

Gain Analysis:

disp(gain_AC);

NaN

% 2. Natural Frequency, Damping Ratio


disp(['Natural Frequency, Damping Ratio:']);

Natural Frequency, Damping Ratio:

disp(['Damping Ratio: ', num2str(damping_info(:, 1)')]);

Damping Ratio: 0 2.0025 9.9975

if size(damping_info, 2) > 1
disp(['Natural Frequency (rad/sec): ', num2str(damping_info(:, 2)')]);
else
disp('Natural Frequency information not available.');
end

Natural Frequency information not available.

% 3. Zeros and Poles


disp(['Zeros and Poles:']);

Zeros and Poles:

6
disp(['Poles: ', num2str(poles_system')]);

Poles: 0 -9.9975 -2.0025

disp(['Zeros: ', num2str(zeros_system')]);

Zeros:

% 4. Characteristics: Settling Time, Rise Time, Overshoot Percentage


disp(['Characteristics: Settling Time, Rise Time, Overshoot Percentage:']);

Characteristics: Settling Time, Rise Time, Overshoot Percentage:

disp(['Settling Time (sec): ', num2str(step_information.SettlingTime)]);

Settling Time (sec): NaN

disp(['Rise Time (sec): ', num2str(step_information.RiseTime)]);

Rise Time (sec): NaN

disp(['Overshoot (%): ', num2str(step_information.Overshoot)]);

Overshoot (%): NaN

% 5. Frequency Response (Bode plot)


disp(['Frequency Response (Bode plot):']);

Frequency Response (Bode plot):

disp(['Frequency (rad/sec): ', num2str(freq)]);

Frequency (rad/sec): 0.1 0.1072267 0.1149757 0.1232847 0.1321941 0.1417474 0.1519911 0.1

% Display magnitude and phase


disp(['Magnitude (dB): ', num2str(20*log10(magnitude(:))')]);

Magnitude (dB): -0.01993282 -0.6276761 -1.235671 -1.843954 -2.452568 -3.061564 -3.670996

disp(['Phase (degrees): ', num2str(phase_angle(:)')]);

Phase (degrees): -93.43192 -93.67955 -93.94499 -94.2295 -94.53443 -94.86124 -95.21146 -

% 6. Impulse Reaction
disp(['Impulse Reaction:']);

Impulse Reaction:

disp(['Time (sec): ', num2str(time_impulse)]);

Time (sec): 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08

disp(['Amplitude: ', num2str(impulse_reaction')]);

7
Amplitude: 0 9.6101e-05 0.00036959 0.00079989 0.0013685 0.0020586 0.0028552 0.0037448 0.0047152 0.005

% 7. Step Reaction
disp(['Step Reaction:']);

Step Reaction:

disp(['Time (sec): ', num2str(time_step)]);

Time (sec): 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08

disp(['Amplitude: ', num2str(step_reaction')]);

Amplitude: 0 3.2354e-07 2.5131e-06 8.2378e-06 1.8972e-05 3.6012e-05 6.0498e-05 9.3426e-05 0.00013566 0.0001

% 8. Ramp Reaction
disp(['Ramp Reaction:']);

Ramp Reaction:

disp(['Time (sec): ', num2str(time_ramp)]);

Time (sec): 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08

disp(['Amplitude: ', num2str(ramp_reaction')]);

Amplitude: 0 8.1367e-10 1.2715e-08 6.2881e-08 1.9419e-07 4.6335e-07 9.3926e-07 1.7015e-06 2.8388e-06 4.4483

You might also like