Question

Need help with this MATLAB question

4.4 (25 points) Write and test the code for the function mysteryFunction that takes a vector, V, generate a new vector W, in

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

function [mysteryMean, mysteryStdev]= mysteryFunction(V)
W=[];
n=length(V);
for i = 1:n
   if i== 1
       W(1)=V(1);
   else
       W(i)=V(i)+V(i-1);
   end
end
W
mysteryMean=mean(W)
mysteryStdev=std(W)
end


OUTPUT:

mysteryFunction (1:8) W = 3 1 5 9 11 13 15 mysteryMean 8 mysteryStdev = 4.8990 ansmysteryFunction ([1:6] . ^2) 1 13 25 41 61 mysteryMean 24.3333 mysteryStdev 23.1056 ans 24.3333

If you have any doubts Let me know in the comment section.

Thank You

Add a comment
Know the answer?
Add Answer to:
Need help with this MATLAB question 4.4 (25 points) Write and test the code for the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Note: I need matlab code and it must be on first entry, output what the question...

    Note: I need matlab code and it must be on first entry, output what the question needs and i need it without any false in the matlab pls program logic: • Find the index of minimum element with min() function. Make sure to take two outputs while using min(), the second output is the location of the minimum element. • replace the element at minimum index with mean(v) • find sum(v) and assign it to output program: function x =...

  • Not enough input arguments error in R line 4 [minvalue , minindex ] = min(v) ;...

    Not enough input arguments error in R line 4 [minvalue , minindex ] = min(v) ; some of ur teams solve it before 20 hr i need a correct code matlab pls Edit the code to the correct code matlab program logic: • Find the index of minimum element with min() function. Make sure to take two outputs while using min(), the second output is the location of the minimum element. • replace the element at minimum index with mean(v)...

  • Matlab code 4) Write a function leadzero(v) which takes as input a vector v and as...

    Matlab code 4) Write a function leadzero(v) which takes as input a vector v and as output, c, returns the number of zeros at the beginning of v (number of zero elements before any non-zero element). For example, for input (-5, 5, 11] the output would be 0. If the input is [0, 0, 3, 0, 0, 0], the output would be 2. If the input is [0, 0, 0, 0, 7, 4) the output would be 4. 5) Write...

  • write it in matlab language Question No 4 6 Marks The surface area and volume of...

    write it in matlab language Question No 4 6 Marks The surface area and volume of the shown ring-shaped mechanical part are calculated respectively as follows: A =rd (2k +d) V = *d? (2R +d) Write a user defined function that computes surface area (A) and volume (V) of this ring from the arguments d and R. Suppose that is constrained to be 15 in, greater than d. Write a script file that uses your function to plot A and...

  • MATLAB HELP PLEASE Write a Matlab function that evaluates a sum of sines at a set...

    MATLAB HELP PLEASE Write a Matlab function that evaluates a sum of sines at a set of points. The first term is just a constant (a coefficient with no sine term). Then, each sine term will have a coefficient before it and then an increasing multiple of the angle inside. For example, consider the sum 3 + 4 sin(9)-1.5 sin (20) 2 sin (40)3 sin (50) We recognize that this is the same as 344sin(101+-1.5 sin (20) + 0 sin...

  • can anyone help with a MatLab code? Problem create a function that takes in the following...

    can anyone help with a MatLab code? Problem create a function that takes in the following vector DATA and returns the number of elements, the mean and the sum of the elements. You can call the function ANALYZER DATA [2 4 5 6 7 8];

  • Circuit Analysis: Need help writing this into MATLAB. I do not need it in paper I need help putting it into MATLAB. * DO NOT WRITE ON PAPER* Please use MATLAB and post your code. Thank you. My work c...

    Circuit Analysis: Need help writing this into MATLAB. I do not need it in paper I need help putting it into MATLAB. * DO NOT WRITE ON PAPER* Please use MATLAB and post your code. Thank you. My work completed. Please help me in make code for the above circuit ^. Here is my work for Part 3 that is needed to complete this part 4. ( could not solve the last part) Part 4. AC Solution by Phasor Analysis...

  • I need help with my python class. thanks! Question 12 Code Example 4-4 main program: import...

    I need help with my python class. thanks! Question 12 Code Example 4-4 main program: import arithmetic as a def multiply(num1, num2):     product = num1 * num2     result = a.add(product, product)     return result     def main():     num1 = 4     num2 = 3     answer = multiply(num1, num2)     print("The answer is", answer) if __name__ == "__main__":     main() arithmetic module: def add(x, y):     z = x + y     return z Refer to Code...

  • To be answered in the form of a Matlab code: Write a code that finds the...

    To be answered in the form of a Matlab code: Write a code that finds the sum of all the positive elements in the input received by the computer as a row matrix (assume all the elements are integers, and there exists at least one positive integer among the input values): Example: ? = [1, -4, 12, -51, -1]                   ? = ?????? = 13

  • Please I need help with MATLAB .. PLease help me . Thankyou Write Matlab code to...

    Please I need help with MATLAB .. PLease help me . Thankyou Write Matlab code to plot a 2D sinc function over a 2D cartesian grid where x ranges from 100 to 355 and y ranges from 0 to 255 and the sinc is centered at somewhere not midway in the grid. First plot the grid, and then plot the function on the grid (both as grayscale and as a surface plot). Comment the code well, generate the figures and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT