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!