Question

Create a function M-ile that will implement a for loop to perform the tollowing tasks for a random input array, tt x. Count how many elements are greater than an arbitrary integer and display these values as well as the count using fprintf. loop to perform the following tasks Create a function M-ile that will implement a for l for a random input array, x. Calculate the arithmentic mean of array, x, without using a built-in function (i.e. sum, average, mean) and display the result using fprintf.Please answer question on MATLAB showing work and the script. Thank you.

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

matlab code for A bit

MATLAB FOR B BIT

function y=calcMean(A)

total=0;

for i=1:length(A);

total=total+A(i);

end

mean=total/length(A);

fprintf('mean is %d',mean);

end

programme

X=randperm(10,5);

disp(X);

calcMean(X);

OUTPUT:

octave:8> X randperm(1e,5); disp(X) calcMean(X)

Add a comment
Know the answer?
Add Answer to:
Please answer question on MATLAB showing work and the script. Thank you. Create a function M-ile...
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
  • Create function files that will use a “for” loop to perform the following tasks for a...

    Create function files that will use a “for” loop to perform the following tasks for a random input array “x”: (a) Count how many elements are greater than an arbitrary integer. Display these values as well as the count using “fprintf”. (b) Calculate the arithmetic mean of array “x” without using the built-in functions “sum”, “mean”, etc. and display the result using “fprintf”.

  • DO THIS IN MATLAB PLEASE DO THIS IN MATLAB Create a script file that performs the...

    DO THIS IN MATLAB PLEASE DO THIS IN MATLAB Create a script file that performs the following calculations. Your script will use the functions you create. Label all graphs appropriately. For this project, do not have your homemade functions fprintf anything, instead have all your fprintf commands within your script. Attach your published script file along with .m files for your functions. Exercise 1. A fundamental iterative method for finding the roots of equations of one-variable is known as Newton's...

  • Create a MATLAB function to perform Lagrange Interpolation. Your function will be used as illustrated below:...

    Create a MATLAB function to perform Lagrange Interpolation. Your function will be used as illustrated below: >> ya = Lagrange(x, y, a) where "x" is a vector of ? independent data values, "y" is a vector of ? dependent function values corresponding to "x", "a" is an arbitrary value of "x" for which you want to know the Westimate of "y", and "ya" is the estimate of the function at x=a. Print an error message and exit the function if...

  • Using MATLAB. Create a script file that calls a user-defined function within a for/end loop to...

    Using MATLAB. Create a script file that calls a user-defined function within a for/end loop to symbolically compute the derivative of ln(x) on the interval from -5 to 5, containing 100 data points. Your script file should output a plot of the derivative of ln(x) (taken from your function) vs x. Use a line with circular markers for the plot and include a grid and appropriate labels. The user-defined function should 1. Receive a single x value as input. 2....

  • specify Output, please. 6. Create a MATLAB script to integrate the given function using the numerical...

    specify Output, please. 6. Create a MATLAB script to integrate the given function using the numerical scheme called Trapezoid's Rule. a. f(x)- xe* +3x1+2x-1 and find for with h 0.1, 0.01 and 0.001 Input: (copy and paste the MATLAB or Scilab command in the following box)

  • Convince yourself that the Maclaurin Series for cos(x) is: A. Write a function script called cos...

    Convince yourself that the Maclaurin Series for cos(x) is: A. Write a function script called cos_series that takes that takes as its inputs, x and N and has output given by the sum in the N-term Maclaurin Series approximation for Cos(x). Hint: try a “for loop” and set “format long” in your code. You may use the MATLAB built-in function factorial() B. Check your code by finding the 2-terms, 3-terms, 4-terms, 5-terms and 6-terms Maclaurin Series approximations every 30 degrees...

  • Use MATLAB to solve this problem. Thank you. Upload the assignment to CANVAS, it should include...

    Use MATLAB to solve this problem. Thank you. Upload the assignment to CANVAS, it should include two things: the PDF and the zipped folder. Late assignments are not accepted. For the questions below, do not create the arrays or matrices by hand. Instead, use built-in MATLAB functions and shorthand notations. Otherwise, no points will be given. 1) Create a function called my product that computes the multiplication of the numbers in any vector using a while loop. The function should...

  • 5. Create a MATLAB script to find the first and second derivative of given function using Forward, Backward, central an...

    5. Create a MATLAB script to find the first and second derivative of given function using Forward, Backward, central and Taylor numerical schemes. Test your code using the following functions: f(x)-xe*+3x2 +2x -1 and find f (3) and f' (3) for with h 0.1, 0.01 and 0.001 b. Approximate y'(1) and y"(1) using the following table f(x) 0.992 0.8 0.9 0.999 1.0 1.001 1.008 Input: (copy and paste the MATLAB or Scilab script in the following box) 5. Create a...

  • Using mat lab to do it Create a single script file named yourname_While.m to answer the...

    Using mat lab to do it Create a single script file named yourname_While.m to answer the following problems. The file must be in cell mode to distinguish each problem. Make sure your script is nicely commented for each problem. Consider the following matrix of values: x =[345, 23, 17, 34, 85, 334, 111, 1067] Use a for loop and if statement to determine how many values greater than 30? Use fprintf to display the result. Repeat Problem 1., but use...

  • In MATLAB code please Problems 1. Create a script file called Lab10.m containing your work for...

    In MATLAB code please Problems 1. Create a script file called Lab10.m containing your work for the following problems to be uploaded to Canvas under Lab 10. 2. Create symbolic expressions for the following and display them using the pretty command ay 2c2 3. Create the following symbolic equations: 3 4. Factor the following expressions and collect like terms: ax2 - 18az+77a 42 +68x +240

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
ADVERTISEMENT