Matlab Help Trying to arranging in order

Discussion in 'Programmer's Corner' started by oshaye3, Mar 11, 2011.

  1. oshaye3

    Thread Starter New Member

    Jan 28, 2011
    2
    0
    Dear all,
    I am trying to arrange this transfer funcion in descending order in order to synchronize with the rest of my code. but it gives me error. look at the results with error. How can I arrange it so that the first order become last TF in the transfer function PLEASE SEE BELOW. ANY LOGIC THANKS. I put the code above as well
    Code:
    den2 = real(den1)
    H1 = tf(1,den2) % Transfer function
    A=den2
    p=polyfact(A)
    p_size=ones(size(p))
    num = num2cell(p_size);
    H2= tf(num,p)

    Transfer function from input 1 to output:
    1
    -----------------
    s^2 + 0.618 s + 1

    Transfer function from input 2 to output:
    1
    -----
    s + 1

    Transfer function from input 3 to output:
    1
    -----------------
    s^2 + 1.618 s + 1

    ??? Undefined function or method 'sort' for input arguments of type 'tf'.

    Error in ==> mbutter at 43
    H2=sort(H2,'descend')
     
  2. etuzuner

    Member

    Mar 21, 2009
    23
    0
    Dear oshaye3,

    I think there is a problem with using tf function, try to create a matrix which represents the order. I guess you need to define the orders even if they do not exist. For example, the order of the denominator is 3. The order of the numerator is 0. I don't remember exactly but I think you need to define numerator as [1 0 0] instead of 1 in tf function. Take a look to the help menu.

    Code ( (Unknown Language)):
    1. doc tf
     
  3. guitarguy12387

    Active Member

    Apr 10, 2008
    359
    12
    The error is because you're using a tf object. It's not a typical data structure or vector.

    Just sort den2 vector before using tf() function.

    Having scalar 1 in the numerator should be fine.
     
Loading...