App designer打包独立桌面App运行结果出错,但matlab内部运行没问题,求解

img


第一个在matlab内部以及开发界面运行及结果正常,第三个独立桌面App在安装后运行报错,但有时不报错,结果有问题
我把目前的运行结果和问题再详细说明一下:
1、在运算过程中,用到自定义函数KM,在matlab内部以及开发界面运行及结果均正确,安装exe后报错,主要错误为Index exceeds the number of array elements. Index must not exceed 1.
2、有两组数据导入运行。
(1)若在打包之前,在开发设计工具界面未导入两组数据,则安装后的exe均无法正常运行,且报错Index exceeds the number of array elements. Index must not exceed 1.
(2)若在打包之前,在开发设计工具界面导入数据1运行,则打包安装后的exe,可正常运行数据1,而导入数据2后报错Index exceeds the number of array elements. Index must not exceed 375.
(3)若在打包之前,在开发设计工具界面导入数据2运行,则大包安装后的exe,可正常运行数据2,而导入数据1后不报错,但表格结果为运行数据2后的结果
global n;
global a;
global zxc;
data=xlsread('zxc1.xls');
x=data(1:n,1);
y=data(1:n,2);
z=data(1:n,3);
data2=zxc;
for j=1:a
l=data(:,j+3);
Z0=data2(j,1);
X0=data2(j,2);
C0=data2(j,3);
v0=data2(j,4);
[,Z(j),X(j),C(j),v(j),]=KM(z,x,c,Z0,X0,C0,v0,l,n,j);
end

img

Index in position 1 exceeds array bounds. Index must not exceed 1.
 
出错 test0/Button_7Pushed (第 547 行)
 
出错 appdesigner.internal.service.AppManagementService/tryCallback (第 181 行)
 
出错 matlab.apps.AppBase>@(source,event)tryCallback(appdesigner.internal.service.AppManagementService.instance(),app,callback,requiresEventData,event) (第 37 行)
 
错误使用 matlab.ui.control.internal.controller.ComponentController/executeUserCallback (第 427 行)
计算 Button PrivateButtonPushedFcn 时出错。