Undefined variable when running appdesigner code
显示 更早的评论
I have some code that works in normal matlab:
if app.Maint_Select.Value == "Seal Coat"
mat = xlsread('Maint.xlsx','B3:Q6');
elseif app.Maint_Select.Value == "Slurry Seal"
mat = xlsread('Maint.xlsx','B9:Q12');
elseif app.Maint_Select.Value == "Overlay"
mat = xlsread('Maint.xlsx','B15:Q18');
end
for k = 1:size(mat,1)
vec = mat(k,:);
A = reshape(vec,[4,4]);
assignin('base',strcat('MAT',num2str(k)),A);
end
%===Defines identity matrix===
I = eye(4);
%===Uses Kronecker Tensor Product to generate all combinations rate matrix for maintenance===
maint_mat=full(KronProd({MAT1,I,I,I})) + full(KronProd({I,MAT2,I,I})) + ...
full(KronProd({I,I,MAT3,I})) + full(KronProd({I,I,I,MAT4})) ;
After pasting this into the code for appdesigner and running it for my app, it comes up with the error saying:
" Undefined function or variable 'MAT1'. " on line 16 of code.
However, 'MAT1' has been defined on line 11 of the code.
Does anyone know why this is happening and how to fix it?
Thank you
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Scope Variables and Generate Names 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!