Problem creating a statespace in Simulink

  • Thread starter Thread starter Twinflower
  • Start date Start date
  • Tags Tags
    Simulink
Click For Summary
The discussion revolves around a two-tank system modeled in Simulink, where liquid flows from tank 1 to tank 2. The user has defined state-space matrices for the system but encounters dimension mismatch errors when running the simulation. The matrices A and B are correctly set as 2x2, but there is confusion regarding the input and output dimensions, particularly with the Constant input and the expected outputs for the tanks. Clarification is needed on how to properly connect the inputs and outputs to resolve the errors. The user plans to seek further assistance from their teacher to address these issues.
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:
-\frac{k}{A_1} x_1 + \frac{k}{A_1} x_2 + \frac{1}{A_1} u

Tank 2:
-\frac{k}{A_2} x_1 + \frac{k}{A_2} x_2 + \frac{1}{A_2} v

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

Similar threads

  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 11 ·
Replies
11
Views
1K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 24 ·
Replies
24
Views
4K