Plotting a response of a circuit on Matlab

Discussion in 'Programmer's Corner' started by tquiva, Feb 14, 2011.

  1. tquiva

    Thread Starter Member

    Oct 19, 2010
    I'm currently working on this assignment:

    I found the transfer function to be:


    I am now on part (f) of the problem:
    I am quite unsure of how to go about solving this in Matlab. I have the following code:

    Code ( (Unknown Language)):
    1. syms s t R real C real;
    2. R = 3 - sqrt(2);
    3. H = (1+R)/(3+s*(4*C+R*C)+s^2*C^2);
    4. in1 = heaviside(t) - heaviside(t-8*pi/C);
    5. IN = laplace(in1,t,s);
    6. OUT1 = IN*H;
    7. out1 = ilaplace(OUT1,s,t)*heaviside(t+eps);
    8. ezplot(subs(out1,R,sqrt(2)),[-1/25]),hold on, legend('R=sqrt(2)'), xlabel('t'),ylabel('out(t)'),title('Response for in1(t)')
    9. in2 = cos(3*C*t)*in1;
    10. IN2 = laplace(in2,t,s);
    11. OUT2 = IN*H;
    12. out2 = ilaplace(OUT2,s,t)*heaviside(t+eps);
    13. ezplot(subs(out2,R,1.414),[-1/25]),hold on, legend('R=sqrt(2)'), xlabel('t'),ylabel('out(t)'),title('Response for in2(t)')
    I then get an error that says:

    ??? Error using ==> ezplot>ezparam at 392
    Cannot plot parametrized surfaces. Try ezsurf.

    Error in ==> ezplot at 163
    hp = ezparam(cax,f{1},f{2},vars,labels,args{2:end});

    Error in ==> sym.ezplot at 50
    h = ezplot(char(f),char(y));

    Right now, I'm really unsure of how to fix this and my assignment is due in a few hours. Could someone please help me asap? Any help is greatly appreciated.
  2. Georacer


    Nov 25, 2009
    I doesn't seem related to the error message, but ezplot can't generate a graph out of an expression with more than one independent sym variable.

    You can see that out1 and out2 are functions of C, s and t by typing:

    The problem lies with Matlab's inability to return OUT1 fully back to the time domain. You can see some ilaplace function call residuals in the out1, if you examine it.

    Maybe that problem is rooted back in the IN function that has left the laplace(heaviside... function intact. Try to calculate that Laplace transform by hand and insert it manually in the IN function.

    P.S. I don't know what to think about this, but Matlab returns 1 as the inverse Laplace transformation of 1/s.