解决Advisor在高版本matlab中无法运行的问题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
时间:2011.8.15
刚解决了Advisor2002无法在高版本运行的问题,我在Matlab2008a和2010上都运行成功!修改步骤如下:
1.将ADVISOR2002patchforR13.m拷进Advisor的文件目录,如E:\Program\Advisor2002下;
2.在Matlab中将运行目录也改为E:\Program\Advisor2002;
3.Matlab的Command Window窗口输入ADVISOR2002patchforR13.m,可以以直接运行ADVISOR2002patchforR13.m,之后会看到Advisor的底层模块被不断更新;
4.更新完成后,在Command Window窗口输入advisor,运行advisor2002,之后点continue,如果Matlab提示出错,则找到出错的文件,一般是“get_cycle_info.m”,将第25行的“break”改成“return”,保存后重新运行advisor2002;继续找到出错的地方,将“break”改成“return”;
5.全部修改完后,advisor2002即可正确运行。如果第三步中更新出错,则可先做第四步,再进行第三步,三四步交替来做,直到没有提示错误。
ADVISOR2002patchforR13.m文件内容如下,大家可以新建个m文件,将下面的内容复制粘贴并保存为ADVISOR2002patchforR13.m即可。
%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
%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