Question: The following function will take three inputs: data, and category, two arrays with numerical data and category labels for data, and selectcat, a category of

The following function will take three inputs: data, and category, two arrays with numerical data and category labels for data, and selectcat, a category of data to return. It returns sift, the data from the selected category.
Which of the following statements about the function below is TRUE?
function [sift]= sifter(data,category, selectCat)
L= length (data)
sift =zeros(1,L)
count =1
for i=1:L
if category (i)== selectCat
sift(i)= data(i);
count = count +1
end
end
sift = sift (1: count-1);
sift should be indexed with count instead of i
The line of code for i=1:L should read for count =1:L
The variable count is unnecessary.
data should be indexed with count instead of i
The following function will take three inputs:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!