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!