Advertisement
Guest User

Difference in the output of lsim()/impulse() between Octave

a guest
Nov 30th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 1.44 KB | None | 0 0
  1. clear
  2. close all hidden
  3.  
  4. t = (0 : 0.1 : 10).';
  5. u = [2.0863, 2.0203, 1.9321, 1.8324, 1.728, 1.6231, 1.5205, 1.4217, 1.3275, ...
  6.      1.2384, 1.1545, 1.0758, 1.0022, 0.93332, 0.86907, 0.80915, 0.75329, ...
  7.      0.70126, 0.65279, 0.60765, 0.56562, 0.52649, 0.49007, 0.45616, 0.42459, ...
  8.      0.39521, 0.36786, 0.3424, 0.3187, 0.29664, 0.27611, 0.257, 0.23921, ...
  9.      0.22265, 0.20724, 0.1929, 0.17955, 0.16712, 0.15555, 0.14478, 0.13476, ...
  10.      0.12543, 0.11675, 0.10866, 0.10114, 0.094138, 0.08762, 0.081552, ...
  11.      0.075904, 0.070647, 0.065753, 0.061198, 0.056957, 0.05301, 0.049335, ...
  12.      0.045915, 0.04273, 0.039766, 0.037006, 0.034437, 0.032045, 0.029817, ...
  13.      0.027744, 0.025813, 0.024014, 0.02234, 0.02078, 0.019327, 0.017974, ...
  14.      0.016713, 0.015539, 0.014444, 0.013424, 0.012472, 0.011585, 0.010758, ...
  15.      0.0099854, 0.0092646, 0.0085915, 0.0079626, 0.0073746, 0.0068246, ...
  16.      0.0063097, 0.0058271, 0.0053745, 0.0049493, 0.0045494, 0.0041726, ...
  17.      0.0038168, 0.0034799, 0.0031597, 0.0028539, 0.0025603, 0.0022757, ...
  18.      0.0019967, 0.0017186, 0.0014351, 0.0011375, 0.00081301, 0.00044306, 0].';
  19.      
  20. sys = ss([0, 1; 2, -3], [0;  1], [1, 0; 0, 1], [0; 0]);
  21.  
  22. y_imp = impulse(sys, t(end));
  23. [y_sim, t_sim] = lsim(sys, u, t, [-0.8; 1].');
  24.  
  25. fprintf('Final value of impulse = (%f/%f)\n', y_imp(end, 1), y_imp(end, 2));
  26. fprintf('Final value of simulation = (%f/%f)\n', y_sim(end, 1), y_sim(end, 2));
  27.  
  28. plot(t_sim, y_sim);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement