how to simulate using lsim command I am receiving error because of variable 't'(time).
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Virendra Kowale
le 13 Fév 2021
Commenté : Star Strider
le 14 Fév 2021
s = -14.5
A = [-3, 5, -7, 0; 0.5, -1.5, 0.5, -7.5; -5, 0, -3, 0; -0.5, -5, 0, -7];
B = [1, 0; 0, -1; -2, 0; 0, 1];
C = [1, 0, 0, 0; 0, -1, 0, 0];
D = [-1, 0; 2, 0];
sys = ss(A,B,C,D);
M = (s*eye(4,4) - A);
P = [ M, -B; C, D]
k = rank(P)
d = det(P)
uM = null(P,'r')
sys2 = tf( sys );
[y,t] = lsim(sys2 ,uM , t)
size(y)
Error that I am receiving:-
When simulating the response to a specific input signal, the input
data U must be a matrix with as many rows as samples in the time
vector T, and as many columns as input channels.
Unrecognized function or variable 't'.
Error in antiresonance_part_two (line 40)
[y,t] = lsim(sys2 ,uM , t)
0 commentaires
Réponse acceptée
Star Strider
le 13 Fév 2021
The input ‘u’ must have the same number of columns as ‘B’.
I have no idea what you actually want to do (or what your ‘u’ is), so in their absence, try this as a relevant (and working) example with your system:
A = [-3, 5, -7, 0; 0.5, -1.5, 0.5, -7.5; -5, 0, -3, 0; -0.5, -5, 0, -7];
B = [1, 0; 0, -1; -2, 0; 0, 1];
C = [1, 0, 0, 0; 0, -1, 0, 0];
D = [-1, 0; 2, 0];
sys = ss(A,B,C,D);
t = linspace(0, 2.5, 250).';
u = sin(2*pi*t*[1 5]);
[y,t] = lsim(sys, u, t);
figure
yyaxis left
plot(t, u(:,1), '--b')
hold on
plot(t, u(:,2), '--r')
hold off
yyaxis right
plot(t, y(:,1), '-b')
hold on
plot(t, y(:,2), '-r')
hold off
grid
xlabel('Time')
ylabel('Amplitude')
legend('u_1', 'u_2', 'y_1', 'y_2', 'Location','N')
Make appropriate changes to get the result you want.
5 commentaires
Star Strider
le 14 Fév 2021
As always, my pleasure!
I was not certain if my changes were what you wanted, so I appreciate your follow-up!
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Time and Frequency Domain Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!