Simulink Matrix multiply error: unexpected scalar signal mismatch
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm confused by a Simulink error relating to a "mismatched port size".
I have a scalar signal in a feedback loop -- the exact configuration isn't relevant (I think), but the point is that it's a number (not vector) as far as I can tell: I know this is a single number, because I can Display it as a single number, and/or Show Value of the wire during running.
If I insert a simple filter inline with this number output from the matrix multiply, I get an error of matrix multiply propagation error.
Here's what works:
I display dims on all signals, so no display means scalar.
This doesn't work:
SL is confused on dims for some reason.
Error:
Why? Isn't a matrix multiply output just a number, if the dimensions end up as 1x1?
What am I misunderstanding?
I haven't found any block options to force proper dims.
2 comentarios
Walter Roberson
el 29 de Abr. de 2023
Why would the dimension end up as 1 x 1? Your second calculation appears to do matrix multiplication of two 1 x 2, which would be an error.
Or possibly your [Kx] is intended to be 2 x 1 -- but Simulink notes 2 x 1 differently than 2 .
If [Kx] is intended to be 2 x 1 your might need to put it through a reshape block.
Respuesta aceptada
Paul
el 29 de Abr. de 2023
That block mutiplies the inputs from top to bottom as if they are left to right. So that block is really doing
xh * Kx,
when you want it the other way around. So make Kx go into the top port and xh into the bottom port.
Then, you need to make sure that Kx is truly a 1x2 vector (or xh is a 2x1). Does Kx source from a Constant block? If it does, make sure that in that block the "Constant value" parameter is a row vector and uncheck the 'Interpret vector paramters as 1D'.
6 comentarios
Paul
el 3 de Mayo de 2023
But why is it neccessary to have the gains as input signals to a subsystem in the first place? If that helps provide you visual clarity of the diagram, or if there is some other reason to structure the model that way, then doing it that way is fine.
All I was saying is that you don't have to do it that way. Instead you can just use Gain blocks where you need them inside the relevant subsystems and set the Gain parameters of those blocks to be the necessary elements of Kd. Doing it this way, the block diagram looks more like the control system you're modeling, IMO. I was just pointing this out in case you weren't aware that a Simulink block parameter can be any Matlab expression, like Kd(1:2); it doesn't have to be a Matlab variable name.
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulink Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!