Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can someone please help me out with this MatLab problem? PLease make sure that the output in MatLab matches the output on the example given
Can someone please help me out with this MatLab problem? PLease make sure that the output in MatLab matches the output on the example given in the problem. Thanks!
PROBLEM 1: Analyzing an Array (30 points) Write a program that performs the following steps. Unless otherwise specified, suppress output to the Command Window (a) Create a variable named Vand assign to it a 250-element row vector whose elements are each randomly generated real numbers chosen uniformly from the open interval (-4.5, 5.5) (b) Create variables numNegative, numPositive, sumPositive, meanPositive, and prodRange. Initialize each variable to an appropriate scalar value. numNegative, numPositive: number of negative and positive elements in V respectively sumPositive, meanPositive: sum of all the positive elements in V respectively prodRange: the product of all real numbers in vector Vin the range [2.3, 2.6] (c) Declare a for-end statement using a loop variable named k that will be assigned to every element of a row vector whose elements represent the indices/positions of row vector V (d) The body of the for-end statement should update, when applicable, the values of numNegative, numPositive, sumPositive, and prodRange. The use of built in functions sum, mean, and prod is NOT allowed. (e) After the for-end statement, compute the mean of the positive real numbers in vector Vand assign the mean to a variable named meanPositive. (f) Using multiple instances of fprintf, display the values contained in variables numNegative, numPositive, sumPositive, meanPositive, and prodRange, respectively Format variables numNegative and numPositive as integers. Format variables sumPositive, meanPositive and prodRange as fixed-point real numbers, each showing a maximum of 3 digits after the decimal point The result of executing your program should look similar to the sample output shown below FIRSTNAME LASTNAME LAB 6 probleml Vector V has 119 negative elements Vector V has 131 positive elements The sum of vector V's positive elements is 363.659 The mean of vector V's positive elements is 2.776 The product of the elements in the range [2. 3, 2.6 is 229.376Step 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