1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Problem creating a statespace in Simulink

  1. Jan 20, 2012 #1
    1. The problem statement, all variables and given/known data

    The problem describes a two tank system where liquid is put into tank 1 and is flowing through a pipe from the bottom of tank 1 into the bottom of tank 2 where it is pumped out from the other side of the tank.

    The liquid level of the tanks are described like this:

    Tank 1:
    [tex]-\frac{k}{A_1} x_1 + \frac{k}{A_1} x_2 + \frac{1}{A_1} u[/tex]

    Tank 2:
    [tex]-\frac{k}{A_2} x_1 + \frac{k}{A_2} x_2 + \frac{1}{A_2} v[/tex]

    k = 0.01 (square meter pr second)
    A1 = 2 (square meter)
    A2 = 1 (square meter)

    The attempt at a solution

    I put this info into the follow matrices:

    A = [-0.005, 0.005; 0.01,-0.01]

    B = [0.5,0; 0,-1]

    C = [0 1]

    D = [0 0]

    (This is the same values i enter in the State-Space dialog box in Simulink)

    After the State-Space block, i put a DeMux followed by two scopes. One for Tank1 and the other for Tank 2.

    The input for the State-Space block is a constant which describes the flow into tank 1.


    This arrangement creates a nasty error messeage i dont understand as I am a newbie when it comes to matlab and simulink.

    Error in port widths or dimensions. Input port 1 of 'oppgave2/State-Space' has 2 elements. This port does not accept the dimensions (or orientation) specified by the input signal.

    Error in port widths or dimensions. Output port 1 of 'oppgave2/Constant' is a one dimensional vector with 1 elements.

    What do I do wrong?
  2. jcsd
  3. Jan 21, 2012 #2

    I like Serena

    User Avatar
    Homework Helper

    Hey Twinflower! :smile:

    I was a bit reluctant to answer your post, since I'm not really a matlab/simulink expert.
    Seeing that no one else has answered your post till now, I thought to give it a shot.

    Your errors appear to indicate that the matrices and vectors that you use do not match in dimensions.

    Let's see which matrices and vectors you have.
    A and B are 2x2 matrices.
    C and D are 1x2 matrices, but what are they for?
    I'm assuming x and u are 2-vectors.
    Can I assume x is actually (x1,x2) and u is actually (u,v)?

    But what are x' and y?
    x' should be a 2-vector representing the levels in your tanks.
    But what is y?

    Anyway, you have a Constant as input to your State-Space, but to which formula would it be input?
    You should have a few inputs and outputs representing x,u resp. x'...
    In particular x' should be connected as output to the scopes. Is it?
  4. Jan 22, 2012 #3
    To be perfectly honest, I don't understand much of this. I tried my best to copy the example from class where Simulink was used. Somehow I must have missed something.
  5. Jan 22, 2012 #4

    I like Serena

    User Avatar
    Homework Helper

    In that case I think it's not an example that is supposed to work in Simulink.
    It would just be a conceptual view of what kind of things are possible.
  6. Jan 22, 2012 #5
    The thing is that the example did work in Simulink. The teacher showed us the graphs depicting the level in the two tanks.

    I think there is some setting or detail I have either overlooked or missed when taking notes.

    I'll send an email to my teacher and try to get a few hints
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook