MATLAB/Simulink error

6 views (last 30 days)
aeropista
aeropista on 27 Jan 2022
Edited: aeropista on 28 Jan 2022
Hello,
I am trying to run this model, where the gains and transport delay are constants.
However, I get the following error and I am not sure why:
Error due to multiple causes.
Caused by:
Error in port widths or dimensions. 'Output Port 1' of '.../Transport Delay' has 2 elements. This port does not accept the dimensions (or orientation) specified by the output signal.
Error in port widths or dimensions. Invalid dimension has been specified for 'Input Port 1' of '.../Gnm'.
Thank you very much for your help!
  4 Comments
aeropista
aeropista on 27 Jan 2022
Indeed, the same error occures for the model in the picture and the one I attached. Here is the workspace I use.
aeropista
aeropista on 27 Jan 2022
and the plant code

Sign in to comment.

Accepted Answer

Jon
Jon on 27 Jan 2022
Edited: Jon on 27 Jan 2022
It looks like your problem may be that you have a SISO (single input single output) transfer function block (Gnm) but the input to it comes from a two dimensional signal and the SISO block doesn't know what to do with the second input signal. The fact that there are two signals seems to trace back to some of the other blocks such as the MATLAB function block within the Plant subsystem whose output signal has dimension of two, and also the integrator block inside that subsystem that has two initial conditions (implying it also provides a two dimensional output.
So either you didn't intend for those blocks to be two dimensional and you will need to correct that, or you need to replace the SISO transfer function block with a MIMO, or at least MISO one.
Finally, your from workspace block ref_signal is only one dimensional, so do you really just want to add that one signal to both of the plant outputs, or again did you intend the output of your plant to be one dimensional.
By the way even with your attached model and the workspace.mat there were some additional errors that needed fixing. Kp and Kr should just be constants, not from workspace blocks unless they are time varying. You also didn't assign a value for the delay parameter of the delay block.
Hope this helps
  3 Comments
Jon
Jon on 28 Jan 2022
Glad you got it working. One thing I was curious about, was the code inside of the MATLAB function block:
function y_dot = fcn(u, dynamics_case, speed_case, transition)
t = u(1);
u_c = u(2);
y_prev = u(3:4);
if transition == 0
y_dot = models.plant(dynamics_case, speed_case, t, u_c, y_prev);
elseif transition == 1
y_dot = models.plant_3_phases(dynamics_case, speed_case, t, u_c, y_prev);
else
y_dot = [0;0];
end
end
I was trying to understand where the function models.plant () is defined. I never have seen that usage before. Is "models" somehow assigned in your MATLAB base workspace?
aeropista
aeropista on 28 Jan 2022
Edited: aeropista on 28 Jan 2022
Indeed, models is a folder in my workspace.

Sign in to comment.

More Answers (0)

Categories

Find more on General Applications in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!