Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this is for MatLab Please I need this in clear writting for the whole question 4

ID: 3670806 • Letter: T

Question

this is for MatLab
Please I need this in clear writting for the whole question

4-) Write the function find_false_locations() that takes in an array of Booleans and returns an array of the numbers that correspond to the indices that are associated with true values. Examples:

a = [ true, false, true, false ];

find_false_locatiosn( a ) % the 2nd and 4th locations are false,
                          % so returns [2, 4]
ans =

         2 4

a = [ false, false, false, true, true, true ];

find_false_locations( a ) % 1st, 2nd, & 3rd locations are false,
                          % so returns [1, 2, 3]
ans =

         1 2 3


a = [ true, true, true ];

find_false_locations( a ) % No values are false, thus
                          % the empty array is returned.

ans =

         []

Explanation / Answer

Let me use java to explain your Requirements.

Hope You understand because the logic is similar irrespective of language.

Here the code. This is Executable code.

import java.util.Scanner;

/**
*
* @author Shivakumar
*/
public class FalseLocation {
static boolean[] array={true,true,true,true,true};
static int[] number={0,0,0,0,0};
public static boolean[] Barray()
{
Scanner sc=new Scanner(System.in);
for(int i=0;i<5;i++)
{
System.out.println("Enter array of boolean values true or false");
  
array[i]=sc.nextBoolean();
}
return array;
  
}
public static void False_Location(boolean[] array)
{
int count=0;
for(int i=0;i<5;i++)
{
if(array[i]==false)
{
number[i]=i;
count++;
}
}
System.out.println("indices of false locations are");
for(int i=0;i<count;i++)
{
System.out.println(number[i]);
}
  
}

public static void main(String args[])

{

FalseLocation.Barray();

FalseLocation.False_Location(array);

}
  
}