Problem creating a statespace in Simulink

  • Thread starter Thread starter Twinflower
  • Start date Start date
  • Tags Tags
    Simulink
Click For Summary

Discussion Overview

The discussion revolves around a problem encountered while creating a state-space model for a two-tank system in Simulink. Participants explore the setup of matrices and the configuration of the Simulink model, addressing issues related to input and output dimensions.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • The initial post describes the mathematical model for the two-tank system and the matrices used in the State-Space block.
  • One participant suggests that the errors may stem from mismatched dimensions between the matrices and the input/output vectors.
  • There is uncertainty about the definitions of the variables involved, particularly regarding the interpretation of x and u as vectors.
  • Another participant expresses confusion about the example used in class, indicating a lack of understanding of how it translates to Simulink.
  • One participant asserts that the example did work in Simulink during class, suggesting that the issue may lie in the details of the participant's implementation.
  • The original poster plans to seek clarification from their teacher regarding the discrepancies in their setup.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the source of the errors, with some suggesting dimension mismatches while others believe the example should work as demonstrated in class. The discussion remains unresolved regarding the specific cause of the issue.

Contextual Notes

There are limitations in understanding the definitions of variables and the expected connections between inputs and outputs in the Simulink model. The discussion does not clarify these aspects fully.

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
2K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 9 ·
Replies
9
Views
7K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 24 ·
Replies
24
Views
4K