Problem creating a statespace in Simulink

  • Thread starter Twinflower
  • Start date
  • Tags
    Simulink
In summary, the problem described 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 problem is 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
  • #1
Twinflower
109
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
  • #2
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?
 
  • #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.
 
  • #4
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.
 
  • #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
 

FAQ: Problem creating a statespace in Simulink

1. How do I create a statespace in Simulink?

To create a statespace in Simulink, you can use the "State-Space" block from the Simulink library. This block allows you to define the state-space model by specifying the system matrices A, B, C, and D. You can also import the state-space model from other software such as MATLAB or use the "State-Space Designer" tool to design the model graphically.

2. What is a statespace in Simulink?

A statespace in Simulink is a mathematical representation of a dynamic system using state variables and their derivatives. It is commonly used to model continuous-time systems and is defined by a set of differential equations. The state variables represent the internal states of the system, while the inputs and outputs represent the external influences and responses of the system, respectively.

3. How do I specify the system matrices for a statespace in Simulink?

You can specify the system matrices for a statespace in Simulink using the "State-Space" block or the "State-Space Designer" tool. The matrix A represents the state dynamics, B represents the inputs, C represents the outputs, and D represents the feedthrough term. You can also specify the matrices using MATLAB code and import them into Simulink.

4. Can I convert a transfer function to a statespace in Simulink?

Yes, you can convert a transfer function to a statespace in Simulink using the "Transfer Fcn to State-Space" block. This block takes in the transfer function coefficients and automatically generates the corresponding state-space model. However, it is important to note that the transfer function must be proper, meaning that the degree of the numerator must be less than or equal to the degree of the denominator.

5. How do I simulate a statespace model in Simulink?

To simulate a statespace model in Simulink, you need to specify the initial conditions for the state variables and provide inputs to the system. You can use various simulation tools such as the "Simulation Stepper" or "Simulation Manager" to run the simulation and visualize the results. Additionally, you can also use the "State-Space Viewer" tool to view the internal states of the system during simulation.

Similar threads

Replies
1
Views
3K
Replies
4
Views
4K
Replies
1
Views
3K
Replies
4
Views
846
Replies
3
Views
2K
Back
Top