Simulink, simout problem

11 visualizzazioni (ultimi 30 giorni)
Alina Abdikadyr
Alina Abdikadyr il 14 Mar 2023
Commentato: Alina Abdikadyr il 19 Mar 2023
Hello everyone, Could you please help me to solve the problim in Simulink, or try to explain what the problem is
Thank yo in advance
I'm using the simulink and matlab to describe the dynamic stability of an aircraft
The error appeared in my Matlab function block:
Caused by:
Error using initializeconstants
Simulink cannot determine sizes and/or types of the outputs for block 'twin_boom_simulation/NonLinear 6DOF plant model/MATLAB
Function' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the
indicated errors, or explicitly specify sizes and/or types for all block outputs.
Error using initializeconstants
Error in port widths or dimensions. 'Output Port 1' of 'twin_boom_simulation/NonLinear 6DOF plant model/MATLAB Function/U' is a one
dimensional vector with 4 elements.
I'm using simout to call the output from the simulink.
%Initize constants for the RCAM simulation
clear
clc
close all
%% Define constants
x0=[85 %approx 165 knots
0;
0;
0;
0;
0;
0;
0.1; %approx 5.73deg
0];
u=[0.1;
0; %approx -5.73 deg
0;
0.08]; %recall for minimum throttle are 0.5*pi/180=0.0087
TF=3*60;
%Define min/max control values
u1min=-25*pi/180; %eulerons
u1max=25*pi/180;
u2min=-25*pi/180; %stabilizer
u2max=10*pi/180;
u3min=-30*pi/180; %rudder
u3max=30*pi/180;
u4min=0.5*pi/180; %thrust 1
u4max=10*pi/180;
%% Run the model
sim('twin_boom_simulation.slx')
%% Plot the results
t=ans.tout;
n=length(t);
u1=ans.simU.Data(:,1);
u2=ans.simU.Data(:,2);
u3=ans.simU.Data(:,3);
u4=ans.simU.Data(:,4);
x1=ans.simX.Data(:,1);
x2=ans.simX.Data(:,2);
x3=ans.simX.Data(:,3);
x4=ans.simX.Data(:,4);
x5=ans.simX.Data(:,5);
x6=ans.simX.Data(:,6);
x7=ans.simX.Data(:,7);
x8=ans.simX.Data(:,8);
x9=ans.simX.Data(:,9);
figure
subplot(5,1,1)
plot(t,u1)
legend('u_1')
grid on
subplot(5,1,2)
plot(t,u2)
legend('u_2')
grid on
subplot(5,1,3)
plot(t,u3)
legend('u_3')
grid on
subplot(5,1,4)
plot(t,u4)
legend('u_4')
grid on
%Plot the states
figure
%u, v, w
subplot(3,3,1)
plot(t,x1)
legend('x_1')
grid on
subplot(3,3,4)
plot(t,x2)
legend('x_2')
grid on
subplot(3,3,7)
plot(t,x3)
legend('x_3')
grid on
%p,q,r
subplot(3,3,2)
plot(t,x4)
legend('x_4')
grid on
subplot(3,3,5)
plot(t,x5)
legend('x_5')
grid on
subplot(3,3,8)
plot(t,x6)
legend('x_6')
grid on
%phi,theta, psi
subplot(3,3,3)
plot(t,x7)
legend('x_7')
grid on
subplot(3,3,6)
plot(t,x8)
legend('x_8')
grid on
subplot(3,3,9)
plot(t,x9)
legend('x_9')
grid on

Risposte (1)

Fangjun Jiang
Fangjun Jiang il 15 Mar 2023
The error is from the Simulink model itself. It can't determine the size of certain signals, most likely from the MATLAB Function block. Open the MATLAB Function block editor, click "Edit Data", set the size of it's input, output and parameters. If the input is a 1x4 vector, set the size to be 4.
  1 Commento
Alina Abdikadyr
Alina Abdikadyr il 19 Mar 2023
Thank you! Here, I specified the sizes for inputs and outputs
The size for input of x should be (9x1); u (4x1); and xdot (9x1), which is output

Accedi per commentare.

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by