Variable size of inline parameters

1 view (last 30 days)
Dennie
Dennie on 6 Oct 2015
Answered: Dennie on 16 Oct 2015
I have made a standalone application out of a Simulink model using the Simulink coder. In this model I have a selection of inline parameters that I set using a GUI.
I use an RTP structure and a batch file to push the inline parameters Can I change the size of these inline parameters after building the standalone application via the gui?
example code:
load('default_rtp.mat') % load the checksum for the rtp structure
clear temp
[temp{1,1}]=deal(rtp.parameters);
rtp=rmfield(rtp,'parameters'); %remove old parameters
values_gui=[handles.var.Ta,handles.var.Voltage,handles.var.cycles,handles.var.displacement,handles.var.load,handles.var.load_prof,handles.var.guess,handles.var.pos_prof,handles.var.prof_select];
names_gui={handles.var.Ta,handles.var.Voltage,handles.var.cycles,handles.var.displacement,handles.var.load,handles.var.load_prof,handles.var.guess,handles.var.pos_prof,handles.var.prof_select};
temp{1,1}.values=values_gui;
rtp.parameters=temp; % push new parameters
clear temp
% where I try to update the dimensions of the signals, this does not work
for i=1:length(rtp.parameters{1,1}.map)
rtp.parameters{1,1}.map(i).Dimensions=size(names_gui{i});
if i==1
rtp.parameters{1,1}.map(i).ValueIndices=rtp.parameters{1,1}.map(i).Dimensions;
else
rtp.parameters{1,1}.map(i).ValueIndices=[rtp.parameters{1,1}.map(i-1).ValueIndices(2)+1,rtp.parameters{1,1}.map(i-1).ValueIndices(2)+size(names_gui{i},2)];
end
end
save(prmFileName,'rtp');
%create bat
fid = fopen(batFileName, 'w');
idx = 1;
outMatFile = [mdlName, '_run',num2str(idx),'.mat'];
cmd = [exeFileName, ...
' -p ', prmFileName, '@', int2str(idx), ...
' -o ', outMatFile, ...
' -L 3600'];
if ispc
cmd = [cmd, ' 2>&1>> ', logFileName];
else % (unix)
cmd = ['.' filesep cmd, ' 1> ', logFileName, ' 2>&1'];
end
fprintf(fid, ['echo "', cmd, '"\n']);
fprintf(fid, [cmd, '\n']);
if isunix,
system(['touch ', logFileName]);
system(['chmod +x ', batFileName]);
end
fclose(fid);
%start simulation
[stat, res] = system(['.' filesep batFileName]);

Accepted Answer

Dennie
Dennie on 16 Oct 2015
I solved it myself by using an empty variable container of size 100x1. I later fill up the container with the number of variable I want and only use that section.

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!