Problem creating a statespace in Simulink

  • Thread starter Thread starter Twinflower
  • Start date Start date
  • Tags Tags
    Simulink
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 9K views
Twinflower
Messages
109
Reaction score
0

Homework Statement



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]

Where:
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.

simulink1.png


This arrangement creates a nasty error messeage i don't 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?
 
Physics news on Phys.org
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?
 
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.
 
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