Circuit in zero state

Thread Starter

tquiva

Joined Oct 19, 2010
176
Hi could someone please help me with this problem.

If I'm not mistaken, the first step would be to find the transfer function?

But what does it exactly mean by "consider the circuit below in zero state" ?



 

t_n_k

Joined Mar 6, 2009
5,455
A circuit is in zero state if it has zero stored energy. In this case the capacitor would have no initial charge.
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
So far, this is what I have for #1:

Rich (BB code):
% a) Impulese response 
% Transfer function H(s)=1/(1+s)
syms t real; syms s; 
H1=1/(1+s);
in1=exp(-2*t)*heaviside(t);
imp1=ilaplace(H1,s,t)*heaviside(t);
pretty(imp1)

% Plot impulse response 
n1=[0 1]; d1=[1 1];
impulse(n1,d1), title('Impulse of in1=exp(-2t)u(t)')

% b) Numeric matlab & convolution for out(t)
% Time vector for non-zero values of input
goin=-7; stopin=0; dt=.01; tin=goin:dt:stopin; in=ones(size(tin))
% Time vector for impulse response 
goimp=0; stopimp=9; timp=goimp:dt:stopimp; imp=exp(-timp);
% Time vector for nat
gonat=goin+goimp; stopnat=stopin+stopimp; tnat=gonat:dt:stopnat;
% Non-zero values of solution
nat = dt*conv(in,imp);
% Plots 
subplot(311),plot(tin,in),xlabel('t'),ylabel('in(t)'),title('')
subplot(312),plot(timp, imp),xlabel('t'),ylabel('imp(t)'),title('')
subplot(313),plot(tnat,nat),xlabel('t'),ylabel('nat(t)'),title('')

% c) Integration to determine out(t)
syms bob real; 
out1=int(subs(in1,t,bob)*subs(imp1,t,t-bob),bob,-inf,inf);
pretty(out1)
out1=simplify(out1)
ezplot(out1)
However, I may need to redo part b. Could someone please check it for me?
And also, for part c, I am getting an error for the ezplot.
What am I doing wrong?
 

Georacer

Joined Nov 25, 2009
5,182
Ok, here 's what I found:

Question a asks for an impulse response, not a step response. The impulse response comes from the command:
Rich (BB code):
imp1=ilaplace(H1,s,t)
Your code
Rich (BB code):
imp1=ilaplace(H1,s,t)*heaviside(t);
, even if you wanted to find the step response, is wrong too by the way.

This code part:
Rich (BB code):
% Plot impulse response 
n1=[0 1]; d1=[1 1];
impulse(n1,d1), title('Impulse of in1=exp(-2t)u(t)')
is correct, but it doesn't utilize the symbolic Matlab toolbox. It is also wrong to say that you have plotted the impulse response for the input in1. The impulse response always corresponds to a dirac input.

For question b, you have made the basic mistake to take the input a series of ones on the negative axis of time, instead of the suggested exp(-2t), so you are dead on arrival. Also I don't understand why do you want to pre-charge the capacitor, since you are told that the system has zero energy stored.
Here 's my suggested code:
Rich (BB code):
t=0:0.05:5;
t2=0:0.05:10;
input=arrayfun(@(t) exp(-2*t),t);
imp=arrayfun(@(t) exp(-t),t);
output=conv(imp,input);
clf
plot(t,input)
hold on
plot(t,imp)
plot(t2,output)
I am not quite sure how you could calculate the output through integration, maybe if you have the theory fresh, you could explain me. But your solution for part c seems to belong more to part 4, since you used the symbolic toolbox.
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
Thank you so much. This really helped.
But I have a question for how you did part b.
On the code:
Rich (BB code):
input=arrayfun(@(t) exp(-2*t),t);
For part c, I know that:


Where bob is a dummy variable.

The problem says to determine out(t) and to plot the solution.

Would this mean that I will have to define a time vector (t) and proceed onto the above integral?

Something like this:
Rich (BB code):
t=0:0.05:10;
bob=0:0.05:5;
out1=int(subs(in1,t,bob)*subs(imp1,t,t-bob),bob,-inf,inf);
pretty(out1)
plot(t,out1)
Although I am getting an error with this code...
 

Attachments

Last edited:

Thread Starter

tquiva

Joined Oct 19, 2010
176
Also, I just noticed.
The impulse response remains the same exp(-t) for all different inputs of the four problems.

Is that correct?
 

Georacer

Joined Nov 25, 2009
5,182
The impulse response is dependant on the system, not the input, so don't worry.

As for part b, I just used the function "arrayfun" that applies a function on each element of an array, that's all. You would have to make a for-loop to do it otherwise.

Concerning the integration, yes I would do what you started doing. Maybe you should make two arrays of the impulse and the input and sum them instead of the integration?
I 'm saying this because the "int" command belongs to the symbolic toolbox and probably is for question d.
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
So, for part b of every problem, when defining the input into the array, all I'd have to do is eliminate the u(-t), u(t), and u(t-7) ?

Like this:
Rich (BB code):
input=arrayfun(@(t) exp(2*t),t);        % #2 
input=arrayfun(@(t) exp(2*t),t);        % #3 
input=arrayfun(@(t) exp(2*(t-7)),t);   % #4
Is this correct?
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
I just reread the problem for part c, and it says to "use integration to determine out(t)", would finding the sum for the arrays of the impulse and input give the same answer as you suggested?

I just can't seem to figure out how to do a type of numerical integration. My code still doesn't seem to work:

Rich (BB code):
t=0:0.05:10;                    % Time vector 
in1=exp(-2*t)*heaviside(t);     % Input 
imp1=ilaplace(H1,s,t);          % Impulse response 
out1=int(subs(in1,t,bob)*subs(imp1,t,t-bob),bob,-inf,inf);
pretty(out1)
 
Last edited:

Georacer

Joined Nov 25, 2009
5,182
Ok, try this one to do the convolution by summation:

I have assumed that you have an initial time vector t, and an output time vector t2 (preferably with double the length). You are also supposed to have the vectors of the input "input" and impulse response "imp".

Rich (BB code):
temp1=size(t);
temp2=size(t2);
output2=zeros(1,temp2(2));
for i=1:temp2(2)
    for j=1:temp1(2)
        if ((i-j)>0)&&(i-j<102)
            output2(i)=output2(i)+imp(j)*input(i-j);
        end
    end
end
The result is pretty similar to the one of the "conv" command.


As for the "int" command of the Symbolic toolbox, you can do something like this:

Rich (BB code):
syms t s bob;
H1=1/(1+s);
imp1=ilaplace(H1,s,t);
imp1=imp1*heaviside(t);
in1=exp(-2*t)*heaviside(t);
out1=int(subs(imp1,t,bob)*subs(in1,t,t-bob),bob,0,10);
%We integrate from 0 to 10 only because this is the space of interest
%typing "out1" will show you the piecewise function that resulted from the integration.
%Select the piece that lies in the [0,10] space and create a second symbolic variable with it.
%Name it "out1inbound".
ezplot(out1inbound,[0,10])
I know that out1inbound is really out of scale and this is a problem, but for now I don't know what is wrong with it.


As for the other inputs, some are right and some are wrong. I am sure that you must create the function for the appropriate time space. That is from -5 to 0 for \(e^{2t} \cdot u(-t)\)
from 0 to whateveryouwant for \(e^{2t} \cdot u(t)\) and \(e^{2(t-7)} \cdot u(t-7)\).

What I don't know is when does the convolution start, that is, which will the time scale for the convolution be. Maybe someone more into Signals and Systems can answer that question.
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
I'm not really familiar with for and if codes on Matlab;
However, I tried putting in values for both the t and t2 vector, and now receive an error that:

??? Undefined function or method 'imp' for input arguments of type 'double'.

Rich (BB code):
t=-5:0.05:5;
t2=-10:0.05:10;
temp1=size(t);
temp2=size(t2);
output2=zeros(1,temp2(2));
for i=1:temp2(2)
    for j=1:temp1(2)
        if ((i-j)>0)&&(i-j<102)
            output2(i)=output2(i)+imp(j)*input(i-j);
        end
    end
end
Could you please assist me on this? And also, will this same exact code work for the other inputs in the other problems ?
 

Thread Starter

tquiva

Joined Oct 19, 2010
176
I redid my method for part d of problem 1:

Rich (BB code):
% d) Symbolic Matlab to verify (c) 
syms in1 imp1 s; syms t bob real; 
H1=1/(1+s);                     % Transfer function
in1=exp(-2*t)*heaviside(t);     % Input 
imp1=ilaplace(H1,s,t);          % Impulse response 
out1=int(subs(in1,t,bob)*subs(imp1,t,t-bob),bob,-inf,inf);
pretty(out1)
ezplot(t,out1),title('out(t) w/ symbolic matlab')
It works, and I got a graph for exp(-t);
Is this correct?
 

Georacer

Joined Nov 25, 2009
5,182
For your first question, it seems that you have used "imp" as a syms object, or you haven't declared it at all. This code works only if "imp" is the array that describes the impulse response over a length of time t2.
Note that the number 102 represents the length of "input" and should be adjusted accordingly.
The code should work for any input vector "input" as long as you replace the 102 with the correct number of simply with "temp3(2)+1" where "temp3=size(input)".

As for the second post, I really don't know. I 'm in bad terms with signals and systems. But shouldn't the output be the same as the one we found in the parts a and b?
 
Top