Undefined variable when running appdesigner code
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Scope Variables and Generate Names in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!