m script
---------------------------------------------------------------------
% Define parameter to be used
var=get_param(gcb,'OutputSignals');
% Find the comma
com = strfind(var,',');
[~,n] = size(com);
sig = cell(n,1);
% Retrieve each signal from strings
for N=1:1:n+1
if N == 1;
sig{N,1} = var(1:com(1)-1);
elseif N > 1 && N
else
sig{N,1} = var(com(N-1)+1:end);
end
end
---------------------------------------------------------------------
2. Automatically input values in specified blocks(Constant block)
m script
---------------------------------------------------------------------
% Model path
mpath = '... / ... /...';
% subsystem path
spath = '... / ... /...';
% Block name
bname = { '...', '...', ... '...'};
% Define values to change
val = [1, 2, ..., n];
% size
[n, ~] = size(val);
% Implementation
try
for N = 1:1:n
fpath = sprintf('%s%s%s',spath,bname,val{N,1});
set_param(fpath,'Value',num2str(val(N,1)));
end
catch
disp(fpath); % Display a path and block name failed to enter
end
No comments:
Post a Comment