Azzera filtri
Azzera filtri

Cell contents reference from a non-cell array object

2 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Walter Roberson
Walter Roberson il 10 Gen 2024
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.

Categorie

Scopri di più su Programmatic Model Editing in Help Center e File Exchange

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by