/home/yourself system name/Documents/MATLAB/psins170617
yourself system name代表你自己的ubuntu系统的名称。
一定要从划横线的地方逐级访问各文件夹,然后找到psinsinit.m文件并且双击打开。
% PSINS Toolbox initialization.
% See also glvs.
% Copyright(c) 2009-2014, by Gongmin Yan, All rights reserved.
% Northwestern Polytechnical University, Xi An, P.R.China
% 09/09/2013, 31/01/2015
initfile = dir('psinsinit.m');
if isempty(initfile) % ~strcmp(initfile.name,'psinsinit.m')
error('Please set the current working directory to PSINS.');
end
%% Remove old PSINS path from search path.
pp = [';',path,';'];
kpsins = strfind(pp, 'psins');
ksemicolon = strfind(pp, ';');
krm = length(kpsins);
for k=1:krm
k1 = find(ksemicolon<kpsins(k),1,'last');
k2 = find(kpsins(k)<ksemicolon,1,'first');
pk = pp(ksemicolon(k1)+1:ksemicolon(k2)-1);
rmpath(pk);
end
%% Add new PSINS directories to search path.
rootpath = pwd;
pp = genpath(rootpath);
mytestflag = 0;
if exist('mytest\mytestinit.m', 'file')
mytestflag = 1;
end
datapath = [rootpath, '\data\'];
if isempty(find(rootpath=='\',1)) % for Unix
rootpath(rootpath=='\')='/';
datapath(datapath=='\')='/';
pp(pp=='\')='/';
end
addpath(pp);
res = savepath; % disp(res);
%% Create PSINS environment file
fid = fopen('psinsenvi.m', 'wt');
fprintf(fid, 'function [rpath, dpath, mytestflag] = psinsenvi()\n');
fprintf(fid, '\trpath = ''%s'';\n', rootpath);
fprintf(fid, '\tdpath = ''%s'';\n', datapath);
fprintf(fid, '\tmytestflag = %d;\n', mytestflag);
fclose(fid);
clear pp rootpath datapath res fid mytestflag;
glvs;
% disp(' *** PSINS Toolbox Initialization Done! ***');
msgbox('PSINS Toolbox Initialization Done!','PSINS','modal')
为什么一定要从划横线的地方访问到psinsinit.m文件?因为代码中的变量pwd代表的地址就是划横线的地方,也就是工具箱的目录。
1.运行psinsinit.m文件,如果出现以下错误,
则将下面的代码注释掉,没出现就不管了。
initfile = dir('sinsinit.m');
if isempty(initfile) % ~strcmp(initfile.name,'psinsinit.m')
error('Please set the current working directory to PSINS.');
end
2.找到如下代码,将代码中的“;”替换为“:”,
pp = [';',path,';'];
kpsins = strfind(pp, 'psins');
ksemicolon = strfind(pp, ';');
替换完后如下所示,
pp = [':',path,':'];
kpsins = strfind(pp, 'psins');
ksemicolon = strfind(pp, ':');
之所以替换,是因为在ubuntu下pp所代表的文件路径之间是以“:”隔开的,而windows下pp所代表的文件路径之间是以“;”隔开的。
3.此时再运行psinsinit.m文件,
哈哈!成功了。可以肆意妄为了。
每次重新打开matlab都要重新初始化工具箱