'Undefined Function or Variable' Error when the variable is perfectly defined!!!!!

조회 수: 1 (최근 30일)
Homayoon
Homayoon 2018년 1월 11일
편집: Homayoon 2018년 1월 12일
Dear MATLAB users,
My code is rather simple and everything is properly defined. Yet I keep receiving error. Can anybody please help me to figure this out? I have spent a lot to see what might cause the problem but could not find any problem.
Here is my code:
Step = [95034, 4, 3, 2, 1, 27, 28, 93464, 93464
98799, 12, 11, 10, 9, 30, 29, 95034, 83288
849220, 24, 23, 26, 25, 35, 36, 841358, 841358
849380, 16, 15, 14, 12, 34, 33, 841358, 841358
881626, 5, 6, 7, 8, 39, 40, 880172, 866342
1070520, 28, 27, 3, 4, 14, 24, 1068914, 1068914];
Config=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 25 26 23 24 33 34 35 36 37 38 39 40 21 22 31 32 30 29 27 28
5 6 7 8 13 14 15 16 17 18 19 20 21 22 31 32 9 10 11 12 25 26 23 24 33 34 35 36 37 38 39 40 1 27 28 4 3 2 30 29
5 6 7 8 4 3 2 13 12 14 15 16 17 18 19 20 25 26 23 24 21 22 31 32 37 38 39 40 9 30 29 1 27 28 10 11 34 33 35 36
5 6 7 8 4 3 2 13 12 14 15 16 17 18 19 20 25 26 23 24 21 22 31 32 37 38 39 40 9 30 29 1 27 28 10 11 34 33 35 36
17 18 19 20 5 6 7 8 4 3 2 13 21 22 15 16 12 34 33 25 35 36 24 31 32 9 30 29 1 27 28 37 38 14 23 26 10 11 39 40
28 27 3 4 9 30 29 20 35 36 25 34 33 17 38 37 1 2 13 16 15 21 5 6 12 8 39 40 10 11 22 7 23 26 18 19 14 24 31 32];
Config2=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 25 26 23 24 33 34 35 36 37 38 39 40 21 22 31 32 30 29 27 28
5 6 7 8 13 14 15 16 17 18 19 20 21 22 31 32 9 10 11 12 25 26 23 24 33 34 35 36 37 38 39 40 4 3 2 28 27 1 30 29
5 6 7 8 4 3 2 13 12 14 15 16 17 18 19 20 25 26 23 24 21 22 31 32 37 38 39 40 9 30 29 1 27 28 10 11 34 33 35 36
5 6 7 8 4 3 2 13 12 14 15 16 17 18 19 20 21 22 31 32 37 38 39 40 9 30 29 1 27 28 25 35 36 24 23 26 10 11 34 33
37 38 14 20 5 6 7 8 4 3 2 13 21 22 15 16 12 34 33 25 35 36 24 31 32 9 30 29 1 27 28 17 18 19 23 26 10 11 39 40
28 27 3 4 9 30 29 20 35 36 25 34 33 17 38 37 1 2 13 16 15 21 5 6 12 8 39 40 10 11 22 7 23 26 18 19 14 24 31 32];
M =[9 0 0 0 2 0
8 1 1 0 1 0
7 2 0 1 2 0
7 2 0 1 2 0
4 5 1 2 1 0
1 8 0 4 2 0];
MMM=[9 0 0 0 2 0 95034 95034
9 0 0 0 2 0 97883 98032
7 2 0 1 2 0 849220 849220
6 3 1 1 1 0 849220 849380
4 5 1 2 1 0 881351 881626
1 8 0 4 2 0 1068914 1068914];
V = load('xav');
for r = 1:size(Step,1)
Test_Verify_Config = Config(r,:);
size (Test_Verify_Config' , 1)
size(((unique(Test_Verify_Config (Test_Verify_Config ~= 0),'stable')).'),1)
ks = Step(r, 1) - 0;
kconfig2 = MMM(r,7);
kconfig3 = MMM(r,8);
klast = Step(r, 8) - 0;
ntot = sum(M(r,:));
Rest of the code...
I keep seeing this error:
Undefined function or variable 'MMM'.
Error in code (line )
kconfig2 = MMM(r,7);
What causes this? I have no idea....Thanks so much in advance.
  댓글 수: 7
Homayoon
Homayoon 2018년 1월 12일
Thank you all for helpful comments. I am not still very sure what causes this but the problem is gone. What I did was close the terminal and re-run the MATLAB. The code worked with no error.
I am using MATLAB installed on a computational cluster, I am not sure if something interrupted or kicked in once the code was running yesterday. All I know at the moment is that the code works just fine with no problem.:-)
Adam
Adam 2018년 1월 12일
Uee functions instead of scripts and these kind of things will happen a lot less, especially if you remove any spurious
clear all
type instructions from your code too.

댓글을 달려면 로그인하십시오.

답변 (1개)

ES
ES 2018년 1월 12일
Step_Atoms is the only suspect. What does the function contain?

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by