How to correct error in port width or dimension in simulink ?

381 ビュー (過去 30 日間)
Achille Jacquemond
Achille Jacquemond 2018 年 6 月 16 日
コメント済み: Guy Rouleau 2024 年 9 月 20 日
I am getting the following port dimension errors when I try to run my simulink model:
"Invalid setting for input port dimensions of 'CONT_assignment/Demux1'. The dimensions are being set to [-1]. This is not valid because the total number of input and output elements are not the same"
"Error in port widths or dimensions. Invalid dimension has been specified for output port 1 of 'CONT_assignment/Transfer Fcn'."
Here is an image of the model. It's a simple PID controller model. The controller gain values are specified in a .m file as global parameters.
Does anyone have a solution for this ?

採用された回答

Walter Roberson
Walter Roberson 2018 年 6 月 16 日
The blocks between Add1 through to Transfer Fcn: set any one of them to explicitly have an output width of 1.
The difficulty you are having is that with your loop the way you have it set up, it would be valid for you to be having a vector of any size being propagated. For example if the vector were of length 5 out of Add1, then that would go into the PID, which would create an output of length 5, which would go into Gain5, which would create an output of length 5, which would go into Gain4, which would create an output of length 5, which would go into Add2 which would produce an output of length 5, which would go into the Transfer Fcn, which would produce an output of length 5, which would go into the DeMux. But the Demux has not been told how to split up that input of length 5 because you have not told it how many values go to which output. If we suppose the bottom one were to get 5 outputs, then that would feed back in to Add1 and the loop would be complete and there would not be any problem with that part -- so a vector output is not inconsistent with any of those blocks. And that in turn means that Simulink cannot deduce what size it is supposed to be using. If you were to fix the output size from any one of the blocks, especially the Add1 block, then Simulink would be able to figure out all of the down-stream sizes.
However, look again at the Demux block. In order to demux, you have to be splitting the input up into multiple paths, so each of the outputs must be smaller than the inputs. So if you were sending a scalar through those Add1 and so on blocks, you would have a scalar out of the transfer fcn, going into the demux. Now you have at least two outputs from the demux but only one input, and that is a problem.
Demux is for splitting vectors. I don't think you want to be splitting the output of the transfer function: I think you want the same scalar output to be going to Add1 and the scope block. Which does not require any block: just connect both to the same input.
  3 件のコメント
Tong Zhao
Tong Zhao 2022 年 1 月 8 日
編集済み: Tong Zhao 2022 年 1 月 8 日
Thank you for the answer, it solved my similar problem too. I was having errors while opening my older models created in MATLAB R2020b in a newer version R2021b. And the error I got was
The dimensions are being set to 1. This is not valid because the total number of input and output elements are not the same
And following your comment I resolved it by forcing one of the blocks on the chain of questionable/undetermined dimension to have an explicit signal dimension of 1.
Mohammad khosravani
Mohammad khosravani 2023 年 5 月 24 日
Hi
I have the same problem with a small difference. I have develpoed a subsystem and every thing works well. but when I put it in a bigger simulation model, I receive this message. the inputs are the same but I do not know what is the problem?

サインインしてコメントする。

その他の回答 (2 件)

Achille Jacquemond
Achille Jacquemond 2018 年 6 月 16 日
Thank you. I removed the Demux and it seems to work.
I just don't understand how to "set any one of them to explicitly have an output width of 1"
How to do this ?
  1 件のコメント
Amru Al Ghafri
Amru Al Ghafri 2020 年 3 月 22 日
Hi
I have same problwm, how did you managed to sort it out

サインインしてコメントする。


Guy Rouleau
Guy Rouleau 2024 年 9 月 20 日

カテゴリ

Help Center および File ExchangeSchedule Model Components についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by