Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 HWnumbers 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
Determine how many numbers in A are divisible by
Calculate the sum of all numbers in A that are greater than
Calculate the mean value of the numbers in A that are less than
Determine how many values in A are equal to the maximum value in
Create a new vector Even that contains only the even numbers in
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
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
Numofs
in one line, find how many elements of vector A are divisible by
Divby
in one line, sum all of the elements of the vector A that are
greater than
SumOver
in one line, find the mean value of all elements of the vector A that are
less than
MeanUnder
in one line, find how many elements are equal to the maximum value in the
vector A
NumberatMax
in one line, create a new vector with all the evenvalued elements in A
Even dots.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started