I am trying to use the test harness to verify the function of my Simulink model. I set the input from Workspace, and write a .m file to build the input structure(I got embedded bus element in my bus object). However,after I ran the Simulink model, all the parameters that I set are all 0, which shows that I didn't successfully configure the input values.
Below is my .m file
clear all;close all;clc;
struct_define_dataGen_new;
% create band_params_dataGen structure
dataKu_struct = Simulink.Bus.createMATLABStruct('band_params_dataGen');
dataC_struct = Simulink.Bus.createMATLABStruct('band_params_dataGen');
% Ku data
dataKu_struct.prf_idx = 1; %
dataKu_struct.transPwr = 1000; %
dataKu_struct.cur_beam_pit = 0; %
dataKu_struct.fc = 8; %
% Cdata
dataC_struct.prf_idx = 1; %
dataC_struct.transPwr = 800; %
dataC_struct.cur_beam_pit = 0; %
dataC_struct.fc = 4; %
% main structure
input_struct = Simulink.Bus.createMATLABStruct('ext_input_dataGen');
% embedded structure value assignment
input_struct.dataKu = dataKu_struct;
input_struct.dataC = dataC_struct;
% fill som other data
input_struct.time_stamp = 0;
input_struct.jammer_relate_rng = 1000;
input_struct.jammer_ang_azi = 10;
input_struct.jammer_ang_pit = 10;
input_struct.wave_type = 0;
% verify
fprintf('=== show value===\n');
fprintf('dataKu.prf_idx = %d\n', input_struct.dataKu.prf_idx);
fprintf('dataKu.fc = %.1f\n', input_struct.dataKu.fc);
fprintf('dataKu.transPwr = %.1f\n', input_struct.dataKu.transPwr);
fprintf('dataC.prf_idx = %d\n', input_struct.dataC.prf_idx);
fprintf('dataC.fc = %.1f\n', input_struct.dataC.fc);
fprintf('dataC.transPwr = %.1f\n', input_struct.dataC.transPwr);
fprintf('wave_type = %d\n', input_struct.wave_type);
fprintf('jammer_relate_rng = %.1f\n', input_struct.jammer_relate_rng);
% create From Workspace structure
ext_input_data.time = [0;1]; %
ext_input_data.signals.values = repmat(input_struct, length(ext_input_data.time), 1); %
ext_input_data.dimensions = 1;
And this is my bus file(struct_define_dataGen_new):
function cellInfo = struct_define_dataGen_new(varargin)
% STRUCT_DEFINE_DATAGEN_NEW3 returns a cell array containing bus object information
%
% Optional Input: 'false' will suppress a call to Simulink.Bus.cellToObject
% when the MATLAB file is executed.
% The order of bus element attributes is as follows:
% ElementName, Dimensions, DataType, Complexity, SamplingMode, DimensionsMode, Min, Max, DocUnits, Description
suppressObject = false;
if nargin == 1 && islogical(varargin{1}) && varargin{1} == false
suppressObject = true;
elseif nargin > 1
error('Invalid input argument(s) encountered');
end
cellInfo = { ...
{ ...
'antennaParaC', ...
'', ...
'', ...
'Auto', ...
'-1', {...
{'dx', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'dy', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'posMat', [12 12], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'M', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'N', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'nCh', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'nTR', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'windValue', [12 12], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'maxAmpTR', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'phaseMaxTR', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'maxAmpCh', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'phaseMaxCh', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'GammaTR', [144 144], 'double', 'complex', 'Sample', 'Fixed', [], [], '', ''}; ...
{'GammaCh', [4 4], 'double', 'complex', 'Sample', 'Fixed', [], [], '', ''}; ...
{'Tmaxice', [4 144], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'abcdMatrix', [4 4], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'SumMatrix', [4 4], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'SumDeltMatrix', [4 4], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'posxGrid', [12 1], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'posyGrid', [12 1], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'elementNum', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'cardxy', [124 3], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'subElementNum', [4 1], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'subArrayCenter', [4 2], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'subArrayWeight', [4 1], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'phi0', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'theta0', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'deltF', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'f0', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'f1', [4 1], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'lambda', [4 1], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
} ...
} ...
{ ...
'antennaParaKu', ...
'', ...
'', ...
'Auto', ...
'-1', {...
{'dx', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'dy', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'posMat', [24 24], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'M', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'N', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'nCh', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'nTR', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'windValue', [24 24], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'maxAmpTR', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'phaseMaxTR', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'maxAmpCh', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'phaseMaxCh', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'GammaTR', [576 576], 'double', 'complex', 'Sample', 'Fixed', [], [], '', ''}; ...
{'GammaCh', [8 8], 'double', 'complex', 'Sample', 'Fixed', [], [], '', ''}; ...
{'Tmaxice', [8 576], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'abcdMatrix', [4 8], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'SumMatrix', [4 4], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'SumDeltMatrix', [4 8], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'posxGrid', [24 1], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'posyGrid', [24 1], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'elementNum', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'cardxy', [424 3], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'subElementNum', [8 1], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'subArrayCenter', [8 2], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'subArrayWeight', [8 1], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'phi0', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'theta0', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'deltF', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'f0', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'f1', [8 1], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'lambda', [8 1], 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
} ...
} ...
{ ...
'antenna_dataGen_output', ...
'', ...
'', ...
'Auto', ...
'-1', {...
{'SubAntennaPattern_Ku', [1 1 8], 'double', 'complex', 'Sample', 'Fixed', [], [], '', ''}; ...
{'SubAntennaPattern32_Ku', [8 1 1 8], 'double', 'complex', 'Sample', 'Fixed', [], [], '', ''}; ...
{'SubAntennaPattern12_Ku', [6 1 1 8], 'double', 'complex', 'Sample', 'Fixed', [], [], '', ''}; ...
{'SubAntennaPattern_C', [1 1 4], 'double', 'complex', 'Sample', 'Fixed', [], [], '', ''}; ...
{'SubAntennaPattern32_C', [4 1 1 4], 'double', 'complex', 'Sample', 'Fixed', [], [], '', ''}; ...
{'SubAntennaPattern12_C', [3 1 1 4], 'double', 'complex', 'Sample', 'Fixed', [], [], '', ''}; ...
} ...
} ...
{ ...
'band_feedback_dataGen', ...
'', ...
'', ...
'Auto', ...
'-1', {...
{'sig_queue', [1 6656], 'double', 'complex', 'Sample', 'Fixed', [], [], '', sprintf('D')}; ...
{'sig_amp', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('发')}; ...
{'power', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('发')}; ...
{'sample_queue', [1 6656], 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('D')}; ...
{'clutter_info', 1, 'Bus: ext_feedback_clutter_dataGen', 'real', 'Sample', 'Fixed', [], [], '', sprintf('杂')}; ...
} ...
} ...
{ ...
'band_params_dataGen', ...
'', ...
'', ...
'Auto', ...
'-1', {...
{'prf_idx', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('重')}; ...
{'transPwr', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('发')}; ...
{'cur_beam_pit', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('当')}; ...
{'fc', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('射')}; ...
{'cur_beam_azi', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('当')}; ...
{'dm_sight_err_azi', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('目')}; ...
{'atte_val_clut', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('杂')}; ...
{'atte_val', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('干')}; ...
{'dm_sight_err_pit', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('目')}; ...
} ...
} ...
{ ...
'ctrl_output', ...
'', ...
'', ...
'Auto', ...
'-1', {...
{'frame_cnt', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
} ...
} ...
{ ...
'ext_feedback_clutter_dataGen', ...
'', ...
'', ...
'Auto', ...
'-1', {...
{'pulse_time_queue', [1 128], 'single', 'real', 'Sample', 'Fixed', [], [], '', sprintf('脉')}; ...
{'pulse_width', 1, 'single', 'real', 'Sample', 'Fixed', [], [], '', sprintf('脉')}; ...
{'prf', 1, 'single', 'real', 'Sample', 'Fixed', [], [], '', sprintf('脉')}; ...
{'polar', 1, 'single', 'real', 'Sample', 'Fixed', [], [], '', sprintf('极')}; ...
{'pulse_num', 1, 'single', 'real', 'Sample', 'Fixed', [], [], '', sprintf('脉')}; ...
{'beam_width_pit', 1, 'single', 'real', 'Sample', 'Fixed', [], [], '', sprintf('波')}; ...
{'beam_width_azi', 1, 'single', 'real', 'Sample', 'Fixed', [], [], '', sprintf('波')}; ...
{'dyt_recv_loss', 1, 'single', 'real', 'Sample', 'Fixed', [], [], '', sprintf('D')}; ...
{'sample_start', 1, 'single', 'real', 'Sample', 'Fixed', [], [], '', sprintf('雷')}; ...
{'pulse_sample_num', 1, 'single', 'real', 'Sample', 'Fixed', [], [], '', sprintf('每')}; ...
{'antenna_loc', [32 2], 'single', 'real', 'Sample', 'Fixed', [], [], '', sprintf('阵')}; ...
} ...
} ...
{ ...
'ext_feedback_dataGen', ...
'', ...
sprintf('模'), ...
'Auto', ...
'-1', {...
{'time_stamp', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('时')}; ...
{'f0', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('D')}; ...
{'fs', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('D')}; ...
{'dataKu', 1, 'Bus: band_feedback_dataGen', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'dataC', 1, 'Bus: band_feedback_dataGen', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
} ...
} ...
{ ...
'ext_input_dataGen', ...
'', ...
sprintf('模'), ...
'Auto', ...
'-1', {...
{'dataC', 1, 'Bus: band_params_dataGen', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'dataKu', 1, 'Bus: band_params_dataGen', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'time_stamp', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('时')}; ...
{'jammer_relate_rng', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('干')}; ...
{'jammer_ang_azi', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('干')}; ...
{'jammer_ang_pit', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('干')}; ...
{'wave_type', 1, 'double', 'real', 'Sample', 'Fixed', [], [], '', sprintf('波;')}; ...
{'patternExtSum', [1 1801], 'double', 'complex', 'Sample', 'Fixed', [], [], '', sprintf('路')}; ...
{'patternExtAzi', [1 1801], 'double', 'complex', 'Sample', 'Fixed', [], [], '', sprintf('路')}; ...
{'patternExtPit', [1 1801], 'double', 'complex', 'Sample', 'Fixed', [], [], '', sprintf('外')}; ...
} ...
} ...
{ ...
'global_data_antenna', ...
'', ...
'', ...
'Auto', ...
'-1', {...
{'AntennaParaKu', 1, 'Bus: antennaParaKu', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
{'AntennaParaC', 1, 'Bus: antennaParaC', 'real', 'Sample', 'Fixed', [], [], '', ''}; ...
} ...
} ...
}';
if ~suppressObject
% Create bus objects in the MATLAB base workspace
Simulink.Bus.cellToObject(cellInfo)
end
I really need to know why that is. How can I successfully set the input value from workspace?