precise selection in a for loop
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
Hello, I just created a for loop and this is correct, but now I would only select positions from 30 to 48 for each "essai" but I am not sur how to do that whithout matrix size problem...
for essai = 1:length (nb_essai)
% for essai = 1:length (nb_essai)
num_ess = [];
num_ess = find (num(:,24) == essai);
Val_CursX_ess = num(num_ess,6);
Val_CursY_ess = num(num_ess,7);
Val_Quest_ess = txt(num_ess,36);
Val_Indice_ess = txt(num_ess,40);
Val_Valid_ess = txt(num_ess,33);
0 件のコメント
回答 (1 件)
Walter Roberson
2015 年 7 月 17 日
After
num_ess = find (num(:,24) == essai);
add
num_ess = num_ess(num_ess >= 30 & num_ess <= 48);
10 件のコメント
Alexandre Williot
2015 年 7 月 17 日
編集済み: Alexandre Williot
2015 年 7 月 17 日
Walter Roberson
2015 年 7 月 18 日
I do not understand that code.
What is class(Question_interet) ? Is it character array or is it cell array of string?
Why are you using those strange find() on strcmp() instead of using the two-output version of ismember() ?
[found, idx] = ismember('string', Cell_Array_Of_Strings)
Alexandre Williot
2015 年 7 月 18 日
Walter Roberson
2015 年 7 月 18 日
Please rewrite your code using ismember()
Also please note that there is no need to test
strcmp() == 1
The result of strcmp() is true or false directly so you can leave out the "== 1" such as
if strcmp(A,B)
or
find(strcmp(A,B))
Alexandre Williot
2015 年 7 月 19 日
Walter Roberson
2015 年 7 月 19 日
Yes, it probably is.
Alexandre Williot
2015 年 7 月 19 日
Walter Roberson
2015 年 7 月 19 日
Okay, so comment out that change of mine, rewrite the resulting version using ismember() and so on, and then uncomment the line and test the resulting code.
Alexandre Williot
2015 年 7 月 19 日
Alexandre Williot
2015 年 7 月 19 日
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!