# Why wont the state-space block accept a mux input?

5 views (last 30 days)
ymps on 3 Jan 2023
Answered: Sam Chak on 4 Jan 2023
I have a state space block with equation modelling the beahvoiur of a buck converter given 2 inputs [Iref and Vin].
I have tried using a Mux, a matrix concatenate and a vector concatenate to pass the 2 signals without sucsess. I get the following errors.
Error in port widths or dimensions. Output port 1 of 'MUx1' is a one dimensional vector with 2 elements.
Error in port widths or dimensions. Invalid dimension has been specified for 'Input Port 1' of 'State-Space'.
I have ensured that the dimensions match, however everytime i do that the error chnages to something new. This also happened with matrix concatenate and vector concatenate blocks
Any help on what might be causing this would be greatly appreciated.

Sam Chak on 4 Jan 2023
,
and you will obviously see that it takes only a SINGLE input u after doing the matrix multiplications.
If the input u is the Voltage input , a function of the reference , where you want to regulate as , then you should design something like this
and the mux is not needed in your case.
tspan = [0 10];
x0 = [1 0];
[t, x] = ode45(@odefcn, tspan, x0);
plot(t, x), grid on, xlabel('t')
y = x(:,1);
y(end)
ans = 0.2000
% State-space model
function xdot = odefcn(t, x)
xdot = zeros(2, 1);
% parameters
Rs1 = 1;
Rs2 = 1;
R = 1;
L = 1;
C = 1;
% elements of matrix A
a11 = - (Rs1 + Rs2 + R)/L;
a12 = - 1/L;
a21 = - 1/C;
a22 = - (Rs1 + Rs2)/C;
% system matrices
A = [a11 a12; a21 a22]; % state matrix
B = [1/L; 0]; % input matrix
% user-design stuff
K = [0.1918 -0.0937]; % user-designed matrix gain
lref = 0.2; % reference
Vin = - K*x + 2.7385*lref; % voltage input
% RLC system
u = Vin; %
xdot = A*x + B*u; % state-space
end

Paul on 3 Jan 2023
The B, C, and D matrices of the state space block indicate the state space model is expecting a single input to generate a single output. At a minimum, the B and D matrices should have two columns if there will be two inputs.

Walter Roberson on 3 Jan 2023
A mux is not the same thing as a vector of values. If you need to build a vector of values use https://www.mathworks.com/help/simulink/slref/vectorconcatenate.html
Paul on 4 Jan 2023
I'm pretty sure there is no difference between the output of the Mux block and of the Vector Concatenate (default settings) block for scalar inputs.

### Communities

More Answers in the  Power Electronics Control

### Categories

Find more on General Applications in Help Center and File Exchange

R2022a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by