Need to delay an input

Thread Starter

kwilson25j

Joined Feb 25, 2012
1
MATLAB CODE
N = 1000;
T = .01;
x = zeros(1,N);

C = 10e-6;
R1 = 1e2; R2 = 1e3;
V1 = 1; V2 = -7;

u = ones(1,N); k = zeros(1,N);


E = [C 0 0 0; 0 0 0 0; 0 0 0 0 ; 0 0 0 0];
A = [0 0 0 1; 1/R1 1 0 0; 1/R2 0 1 0; 0 1 1 -1];
B = [0 0; -1/R1 0; 0 -1/R2; 0 0];

EmTAinv = inv(E-T*A);
TB = T*B;

X = EmTAinv*E; Y = EmTAinv*TB;

v1 = V1*u; v2 = V2*u;
U = [v1;v2];

for n = 1:N
x(n+1) = X*x(n)+Y*U;
end

t = T*[1:N];
plot(t,x)
This code is for simulating the time response of a circuit with two input voltages, v1 and v2. Solving the differential equations can be set up as matrices in matlab.


This is my code thus far. I would like to delay my "v2" input by 2 seconds. How would I possibly go about this?

Also, I am having problems simulating this time response without any delay, and I have noticed that my matrix dimensions must agree. I know that there will be a 4x4 and a 4x2 in my output, x, but my teacher assured us that this would work easily.

Thanks for any help.
 
Last edited:
Top