Circuit in zero state

Discussion in 'Homework Help' started by tquiva, Mar 22, 2011.

Oct 19, 2010
176
2

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" ?

2. t_n_k AAC Fanatic!

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

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

Code ( (Unknown Language)):
1. % a) Impulese response
2. % Transfer function H(s)=1/(1+s)
3. syms t real; syms s;
4. H1=1/(1+s);
5. in1=exp(-2*t)*heaviside(t);
6. imp1=ilaplace(H1,s,t)*heaviside(t);
7. pretty(imp1)
8.
9. % Plot impulse response
10. n1=[0 1]; d1=[1 1];
11. impulse(n1,d1), title('Impulse of in1=exp(-2t)u(t)')
12.
13. % b) Numeric matlab & convolution for out(t)
14. % Time vector for non-zero values of input
15. goin=-7; stopin=0; dt=.01; tin=goin:dt:stopin; in=ones(size(tin))
16. % Time vector for impulse response
17. goimp=0; stopimp=9; timp=goimp:dt:stopimp; imp=exp(-timp);
18. % Time vector for nat
19. gonat=goin+goimp; stopnat=stopin+stopimp; tnat=gonat:dt:stopnat;
20. % Non-zero values of solution
21. nat = dt*conv(in,imp);
22. % Plots
23. subplot(311),plot(tin,in),xlabel('t'),ylabel('in(t)'),title('')
24. subplot(312),plot(timp, imp),xlabel('t'),ylabel('imp(t)'),title('')
25. subplot(313),plot(tnat,nat),xlabel('t'),ylabel('nat(t)'),title('')
26.
27. % c) Integration to determine out(t)
28. syms bob real;
29. out1=int(subs(in1,t,bob)*subs(imp1,t,t-bob),bob,-inf,inf);
30. pretty(out1)
31. out1=simplify(out1)
32. 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?

4. Georacer Moderator

Nov 25, 2009
5,150
1,271
Ok, here 's what I found:

Question a asks for an impulse response, not a step response. The impulse response comes from the command:
Code ( (Unknown Language)):
1.
2. imp1=ilaplace(H1,s,t)
3.
Code ( (Unknown Language)):
1.
2. imp1=ilaplace(H1,s,t)*heaviside(t);
3.
, even if you wanted to find the step response, is wrong too by the way.

This code part:
Code ( (Unknown Language)):
1.
2. % Plot impulse response
3. n1=[0 1]; d1=[1 1];
4. impulse(n1,d1), title('Impulse of in1=exp(-2t)u(t)')
5.
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:
Code ( (Unknown Language)):
1.
2. t=0:0.05:5;
3. t2=0:0.05:10;
4. input=arrayfun(@(t) exp(-2*t),t);
5. imp=arrayfun(@(t) exp(-t),t);
6. output=conv(imp,input);
7. clf
8. plot(t,input)
9. hold on
10. plot(t,imp)
11. plot(t2,output)
12.
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.

Oct 19, 2010
176
2
Thank you so much. This really helped.
But I have a question for how you did part b.
On the code:
Code ( (Unknown Language)):
1. 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:
Code ( (Unknown Language)):
1. t=0:0.05:10;
2. bob=0:0.05:5;
3. out1=int(subs(in1,t,bob)*subs(imp1,t,t-bob),bob,-inf,inf);
4. pretty(out1)
5. plot(t,out1)
Although I am getting an error with this code...

• Screen shot 2011-03-27 at 1.03.10 PM.png
File size:
9.2 KB
Views:
74
Last edited: Mar 27, 2011

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

Is that correct?

7. Georacer Moderator

Nov 25, 2009
5,150
1,271
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.

Oct 19, 2010
176
2
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:
Code ( (Unknown Language)):
1.
2. input=arrayfun(@(t) exp(2*t),t);        % #2
3. input=arrayfun(@(t) exp(2*t),t);        % #3
4. input=arrayfun(@(t) exp(2*(t-7)),t);   % #4
Is this correct?

Oct 19, 2010
176
2
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:

Code ( (Unknown Language)):
1. t=0:0.05:10;                    % Time vector
2. in1=exp(-2*t)*heaviside(t);     % Input
3. imp1=ilaplace(H1,s,t);          % Impulse response
4. out1=int(subs(in1,t,bob)*subs(imp1,t,t-bob),bob,-inf,inf);
5. pretty(out1)
6.

Last edited: Mar 29, 2011
10. Georacer Moderator

Nov 25, 2009
5,150
1,271
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".

Code ( (Unknown Language)):
1.
2. temp1=size(t);
3. temp2=size(t2);
4. output2=zeros(1,temp2(2));
5. for i=1:temp2(2)
6.     for j=1:temp1(2)
7.         if ((i-j)>0)&&(i-j<102)
8.             output2(i)=output2(i)+imp(j)*input(i-j);
9.         end
10.     end
11. end
12.
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:

Code ( (Unknown Language)):
1.
2. syms t s bob;
3. H1=1/(1+s);
4. imp1=ilaplace(H1,s,t);
5. imp1=imp1*heaviside(t);
6. in1=exp(-2*t)*heaviside(t);
7. out1=int(subs(imp1,t,bob)*subs(in1,t,t-bob),bob,0,10);
8. %We integrate from 0 to 10 only because this is the space of interest
9. %typing "out1" will show you the piecewise function that resulted from the integration.
10. %Select the piece that lies in the [0,10] space and create a second symbolic variable with it.
11. %Name it "out1inbound".
12. ezplot(out1inbound,[0,10])
13.
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.

Oct 19, 2010
176
2
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'.

Code ( (Unknown Language)):
1. t=-5:0.05:5;
2. t2=-10:0.05:10;
3. temp1=size(t);
4. temp2=size(t2);
5. output2=zeros(1,temp2(2));
6. for i=1:temp2(2)
7.     for j=1:temp1(2)
8.         if ((i-j)>0)&&(i-j<102)
9.             output2(i)=output2(i)+imp(j)*input(i-j);
10.         end
11.     end
12. end
Could you please assist me on this? And also, will this same exact code work for the other inputs in the other problems ?

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

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

13. Georacer Moderator

Nov 25, 2009
5,150
1,271
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?