[help] plotting transfer function on matlab

Discussion in 'Programmer's Corner' started by cupcake, Oct 2, 2010.

  1. cupcake

    Thread Starter Member

    Sep 20, 2010
    73
    0
    Hello, I did the experiment about open-loop step test, from the experiment, I got data to plot the unit step response, then the question ask me to fit a first-order plus dead-time model according Ziegler-Nichols step response method
    Gp(s) = (\frac{Kp}{sT+1} ) e^{-sL} (sorry the delayed should go a slightly more upward) and then superimpose the unit step response from the estimated first-order plus dead-time model on the experiment.

    I'm not quite sure how to do this using matlab, I meant the superimpose part.
    from Gp(s) with unit step response input, I could find the y(s) and in time domain y(t)=Kp(1 -  e^{(-t+L)/T})*1(t-L)

    I know we could use something called "hold on" or "hold off" in matlab, but when I tried to type in the formula of y(t). the errors come out.. can anyone advise please.
     
  2. guitarguy12387

    Active Member

    Apr 10, 2008
    359
    12
    Could ya post some code? It's a little hard to know what ya mean by the description.
     
  3. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,386
    496
    Step 1. Define the range of s, in MatLab: s=0:0.01:3.14;
    (0.01 is the increment, so you go 0, 0.01, 0.02, 0.03, etc.)

    Step 2. Input formula of the transfer function, you need to know Kp, T, L. If you do not know values of Kp, T, and L, you are done. You are not going to plot anything. Do you have values for these three things?
     
    Last edited: Oct 6, 2010
  4. cupcake

    Thread Starter Member

    Sep 20, 2010
    73
    0
    I don't know the value of Kp, T and L, but I have 50 input data (for unit step) in 24.5 minutes range, from this.. I could plot unit step response graph.. could I just approximate the value of Kp, T and L from the reading...Kp is just a steady state gain, L is dead time, but what about T? I'm not quite sure.
     
  5. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,386
    496
    There should be some formulas to approximate values of Kp, T and L. The only unknown should be the s.
     
  6. t_n_k

    AAC Fanatic!

    Mar 6, 2009
    5,448
    782
    Check out Section3 in this paper - Figure 4 will be of interest.
     
    Last edited: Oct 7, 2010
  7. cupcake

    Thread Starter Member

    Sep 20, 2010
    73
    0
    ok, then from the pdf you gave me, I could approximate the value of Kp, T and L.. now, how do i superimpose this ziegler-nichols formula using mat lab? I don't know what code to use,do I plot in in time domain? or in s domain? and btw, I have the values of s (from the experiment reading).
     
  8. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,386
    496
    In matlab, when you use plot, you can plot multiple functions. For example:
    Define inputs for the first function:
    x1=0:0.01:10;
    Define first function:
    y1=2*x1;

    Define inputs of the second function:
    x2=0:0.01:10
    Define second function:
    y2=x2-3;

    Now bring them all together to plot:
    plot(x1, y1, x2, y2);

    Do you see what I did inside the prenticies of the plot command? MatLab will automatically plot the two functions on the same coordinate plane and keep track which values belong to which function. This way you can easily see how the two functions are similar or different from each other.
     
  9. t_n_k

    AAC Fanatic!

    Mar 6, 2009
    5,448
    782
    If I understand Cupcake's dilemma it is in relation to handling plots of functions which include a time shift.

    A 'simple' way around this is to recognize that the Z-N function is a first order delay with an ideal time shift.

    To make the required comparison one would generate a time series pair array of the first order delay part and then apply a fixed time offset to the all the time components of the array. This could then be overlay-ed with the original experimental data for the purposes of comparison.

    Another approach is to use the Pade approximation to the delay component of the Z-N 's' domain transfer function and then derive the 'approximate' time domain equivalent which could then be plotted without resort to applying the aforementioned time shift.

    I don't use Matlab so I can't be of any help in relation to what relevant functions are included in the various toolboxes at your disposal.
     
  10. cupcake

    Thread Starter Member

    Sep 20, 2010
    73
    0
    -deleted-..........
     
    Last edited: Oct 9, 2010
  11. cupcake

    Thread Starter Member

    Sep 20, 2010
    73
    0
    Ok, I will give a try, thanks
    Btw, is there any matlab function/formula to calculate or find the area below the graph? I think I could find the Kp, L and T by using the method of area. But, I'm afraid if I'm calculating it manually, there will be an error

    ok sir, from the pdf you gave me, i could estimate the value of Kp, L and T from the graph. for L and T, should they be in seconds or can be in minutes? I have my x-axis in minutes, so i shall convert them right?
     
  12. cupcake

    Thread Starter Member

    Sep 20, 2010
    73
    0
    I want to plot this y(t1)=kp*(1-e^(-t1-L)/T)*1(t1-L)
    whereby Kp=0.258, L=0.565, and T=6.5 and t1 is time starting from 0 to 24.5 (in minutes)

    I got this error message..
    >> y1=kp*(1-exp((-t1-L))/T)*(-t1-L)
    ??? Error using ==> mtimes
    Inner matrix dimensions must agree.

    so, how should I type in the formula?
     
Loading...