%this file will update all the block diagrams in the models directory in ADVISOR
%so that they will work in Mathworks Release 13. This assumes that you have ADVISOR 2002
%and it is already included in your Matlab path which is done automatically when you type
%advisor at the command prompt.
%
% place this file in your current working directory in Matlab and type it's name.
%
% Here's what we posted on the advisor community web site regarding this error.
%
% Aug-30-2002 7:22 AM
%
% Regarding the boolean type problem in R13: Release 13 of Matlab has introduced
% a new type called logical. The problem is in the block diagrams in the accessory
% loads masked subsystem. Go to BD_PAR for instance and click on "mechanical accessory loads "
% then click on the "Mechanical Accessory Loads V2 " block. You will see a mask window pop
% open. At the top, you will see the "not" function used. In release 12 and earlier, this
% function returned a 1 or a 0 for true and false. Now it returns a new type, logical. This
% is causing the problems. To fix the problem, multiply by 1 (which causes a type change
% to double). That should fix the logical errors.
clear all
%change directories to the models directory
cd(strrep(which('advisor.m'),'advisor.m','models'))
%get the list of everything in the models directory
dir_list=dir;
%For the items in the directory that are .mdl files, do the following
k=1;
for i=1:length(dir_list)
if ~isempty(strfind(dir_list(i).name,'.mdl'))
%suppress warnings
warning off
open_system(dir_list(i).name);
system=find_system(strrep(dir_list(i).name,'.mdl',''), 'RegExp','on', 'Name', 'Mechanical Accessory\nLoads v2 <acc>');
%if the system in question is found do the following
if ~isempty(system)
%fix the system name
z=isspace(system{1}); %find spaces and carriage returns and make sure they are just spaces
for j=1:length(system{1});
if z(j)==1 ;
system{1}(j)=' ';
end
end
settings=get_param(system,'maskvalues');
if strcmp(settings{1}{1},'not(ess_on)') %check to see if already fixed
settings{1}{1}='not(ess_on)*1'; %add the *1 to make it a real number instead of a boolean
set_param(system{1},'maskvalues',settings{1}) %set the mask values
save_system(strrep(dir_list(i).name,'.mdl','')); %save the block diagram
saved_systems{k,1}=dir_list(i).name; %keep track of what models were updated
k=k+1;
end
end
close_system(strrep(dir_list(i).name,'.mdl',''))
end
end
disp('ADVISOR2002 update for it to run in R13 of Matlab')
if exist('saved_systems')
disp('the following block diagrams were changed and saved:')
disp(saved_systems)
else
disp('no block diagrams in the models directory needed to be updated')
end
warning on