Question: Logical Indexing and Vector Practice The provided file named HW 6 _ numbers . mat contains a vector A of unknown length with random integers

Logical Indexing and Vector Practice
The provided file named HW6_numbers . mat contains a vector A of unknown length with random integers in it. Modify the provided MATLAB script so that it
performs the operations listed below. Every task described below must use logical indexing. For your convenience, the tasks are also repeated in the comments of
the code.
Determine how many elements in A are equal to 4.
Determine how many numbers in A are divisible by 3.
Calculate the sum of all numbers in A that are greater than 45.
Calculate the mean value of the numbers in A that are less than 70.
Determine how many values in A are equal to the maximum value in A.
Create a new vector Even that contains only the even numbers in A.
Fill in the places in the code marked ... with code to accomplish the tasks. Hint: there may be a place or two where you find the mod function useful.
Script o.
% housekeeping commands would go here, but we leave them out to keep Grader happy
%bring in data from data file
...
%in one line, find how many elements of vector A are equal to 4
Num_of_4s =...
%in one line, find how many elements of vector A are divisible by 3
Div_by_3=...
%in one line, sum all of the elements of the vector A that are
%greater than 45.
Sum_Over_45=...
%in one line, find the mean value of all elements of the vector A that are
% less than 70.
Mean_Under_70=...
%in one line, find how many elements are equal to the maximum value in the
%vector A
Number_at_Max =...
%in one line, create a new vector with all the even-valued elements in A
Even =dots.
 Logical Indexing and Vector Practice The provided file named HW6_numbers .

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 Databases Questions!