필터 지우기
필터 지우기

Cell contents reference from a non-cell array object

조회 수: 2 (최근 30일)
Joseph Pinkston
Joseph Pinkston 2024년 1월 10일
답변: Walter Roberson 2024년 1월 10일
I have a Matlab Function inside of a top-levelk Simulink model that references an external model 'Airbrake_Dynamics_Model_Test'. When calling this external model, I am attempting to set the inputs to the external model inside of the Matlab Function. However, I am getting the error "Cell contents reference from a non-cell array object" on line 28. inDS is a strucutre, I am trying to implement the setExternalInput method that is very similar to the example one used in the documentation. However, when setting the individual structures, I am getting the error.
function [x_new, z_new, x_dot_new, z_dot_new, theta_new, apogee_expected] = Dynamics_Model(x_0, z_0, x_dot_0, z_dot_0, theta_0, U)
coder.extrinsic('createInputDataset')
mdl = 'Airbrake_Dynamics_Model_Test';
global inDS
inDS = nan(1,1);
inDS = createInputDataset(mdl);
constStruct1.time = [0 25]';
constStruct1.signals.values = [U U]';
constStruct2.time = [0 25]';
constStruct2.signals.values = [x_0 x_0]';
constStruct3.time = [0 25]';
constStruct3.signals.values = [z_0 z_0]';
constStruct4.time = [0 25]';
constStruct4.signals.values = [x_dot_0 x_dot_0]';
constStruct5.time = [0 25]';
constStruct5.signals.values = [z_dot_0 z_dot_0]';
constStruct6.time = [0 25]';
constStruct6.signals.values = [theta_0 theta_0]';
inDS{1} = constStruct1;
inDS{2} = constStruct2;
inDS{3} = constStruct3;
inDS{4} = constStruct4;
inDS{5} = constStruct5;
inDS{6} = constStruct6;
simIn = Simulink.SimulationInput(mdl);
simIn = setExternalInput(simIn,inDS);
out = sim(mdl);
x_new = (out.yout{1}.Values.Data(8));
z_new = (out.yout{2}.Values.Data(8));
x_dot_new = (out.yout{3}.Values.Data(8));
z_dot_new = (out.yout{4}.Values.Data(8));
theta_new = (out.yout{5}.Values.Data(8));
apogee_expected = (out.yout{2}.Values.Data(end));
end
  댓글 수: 1
Stephen23
Stephen23 2024년 1월 10일
Note that
[0 25]'
requires two operations, whereas
[0;25]
uses only one.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2024년 1월 10일
Try
inDS(1) = constStruct1;
This assumes that inDS has only fields time and signals . If it has additional fields then there is no MATLAB syntax for assigning multiple fields at the same time.

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by