Matrix Error

5 次查看(过去 30 天)
Kyle
Kyle 2012-4-20
Greetings,
I am trying to model the system X(s)/E(s) = (-20.5s+41)/(s^2+7s+10). Where E(s) = U(s) - (X(s)^2-X(s)). U(s) is an impulse.
It is a negative feedback system in the s-domain.
The line e=... represents the calculation of the error of a feedback.
E
U --->+---->G(s)----->X(s)
^ |
| |
----(?)------
Where the output of (?) is represented by X(s)^2 - X(s).
So E(s) is the input of G(s) and X(s) is the output of G(s). It is a negative feedback system, so E(s) is represented by U(s)-( X(s)^2 - X(s)).
The block, (?), cannot be treated as X(s)-1.
Best way I could explain it...
I am getting an error
In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in SysSimHW10p1 (line 45)
xdot1(2) = -7*x(2) - 10*x(1) + e;
that I am having trouble fixing.
% X(s) -20.5s + 41
%----- = --------------
% E(s) s^2 + 7s + 10
% E(s) = U(s) - [ (X(s)^2 - X(s) ]
clear all
close all
clc
N = 450;
T = .01;
X = [0 0];
x = zeros(1,N);
u = zeros(1,N);
xdot1 = x;
xdot2 = xdot1;
for n = 1:N-1
u(1) = .01;
e = u - x.*x + x;
xdot1(1) = x(2);
xdot1(2) = -7*x(2) - 10*x(1) + e;
x = x + (T/2)*(3*xdot1 - 1*xdot2);
xdot2 = xdot1;
X = [X (-20.5*x(2) + 41*x(1))];
end
t = T*[0:length(X)-1];
plot(t,X)
title('Impulse Response of System')
xlabel('Time')
ylabel('Amplitude')
Any help is appreciated!

回答(1 个)

Geoff
Geoff 2012-4-20
Well, u is a 1x450 vector, and x is a 1x3 vector. You can't add those together.
What is that line of code supposed to mean?
  3 个评论
Geoff
Geoff 2012-4-20
Okay, and what is 's'? I notice it's not in your code. Is that because you can use vector-operations to compute the entire X(s) without looping, or is that what you're doing with 'n'?
Everywhere else you use 'x', you're taking a scalar out of it (x(1), x(2)). Could it be that you're meant to do this for the line where your error occurs? Or should you be taking u(n) instead of u?
Kyle
Kyle 2012-4-20
s just means that the functions are represented in my problem as S-domain functions---Laplace transfer functions. They represent a simplified version of differential equations. To program these equations they are converted back to time-domain representations. Ignore the s and just think of it in terms of X, G, U, E..I guess.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by