MATLAB: Write a script that given a vector, called A, of n numbers, outputs the index of the first number divisible by 3. Sample Output: Given A = [5, 4, 6, 7, 3] divisible by 3 is:3
homework
The index first number divisible by 3 is: 3
but I do not know how to get the position from the vector.
Best Answer
A = [5, 4, 6, 7, 3];
idx=find(mod(A,3)==0); % Gives the index number / Position
Best Answer