What is wrong with my script?
조회 수: 1 (최근 30일)
이전 댓글 표시
Who could help me? What is wrong with my script? There is no counting...
index_aanname = find(strcmp(alldata(:,5), 'Aanname') == 1);
TA = tijdnum(index_aanname);
TA10 = TA - 10;
SA = speler(index_aanname);
bal = 0 ;
medespeler_met_bal = 0 ;
medespeler_zonder_bal = 0 ;
tegenstander = 0 ;
open_ruimte = 0 ;
overzicht_veld = 0 ;
overig = 0 ;
for k = 1:length(index_aanname)
firstTouchIndex = index_aanname(k);
firstTouchTimestamp = alldata{firstTouchIndex,1};
j = firstTouchIndex - 1;
while j >= 1 && (firstTouchTimestamp - alldata{j,1}) <= 10.0
viewingBehaviour = alldata{j,9};
j = j - 1;
if strcmp(kijkrichting(i),'Bal') == 1
bal = bal + 1
elseif strcmp(kijkrichting(i),'Medespeler met bal') == 1
medespeler_met_bal = medespeler_met_bal + 1;
elseif strcmp(kijkrichting(i),'Medespeler zonder bal') == 1
medespeler_zonder_bal = medespeler_zonder_bal + 1;
elseif strcmp(kijkrichting(i),'Tegenstander') == 1
tegenstander = tegenstander + 1;
elseif strcmp(kijkrichting(i),'Open ruimte') == 1
open_ruimte = open_ruimte + 1;
elseif strcmp(kijkrichting(i),'Overzicht veld') == 1
overzicht_veld = overzicht_veld + 1;
elseif strcmp(kijkrichting(i),'Overig') == 1
overig = overig + 1;
end
end
end
댓글 수: 2
Rik
2018년 6월 8일
Have you tried the debugger? You can set breakpoints to stop the execution of your code and continue step by step. That way you can watch the point where variables take on unexpected values. The debugging capabilities are one of the main features in Matlab that are superior to programs like Octave. You should really use it.
Jan
2018년 6월 9일
By the way: There is no reason to compare the output or strcmp with 1. strcmp replies a logical value already:
if strcmp(kijkrichting(i), 'Bal')
답변 (1개)
Image Analyst
2018년 6월 8일
Since kijkrichting is being compared to strings, it's most likely a cell array. Therefore you should be using {} instead of (). See the FAQ for a good explanation of when to use bracket, braces, or parentheses: https://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
So use kijkrichting{i} instead of kijkrichting(i).
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!