Question

Take 10 numbers from the user. Calculate their mean and median with your code, not using...

Take 10 numbers from the user. Calculate their mean and median with your code, not using builtin Matlab functions. Print these values on the screen with a special format using the command: fprintf.

Homework Answers

Answer #1

Ques:

Ans:

Matlab code:

clear all ;
close all;
clc
x = 'enter the 10 point like [x1 x2 x3 ... x10] ' ;
data = input(x) ; %take data from user
input_data = data
input_sort = sort(data)
n = length(data)
mean_value = sum(data)/n
median_value = (input_sort((n/2)) + input_sort((n+2)/2))/2 % n should be even in this case

fprintf('mean value of 10 input data = %d \n ',mean_value)
fprintf('median value of 10 input data = %d \n ',median_value)

Result:

Know the answer?
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
Similar Questions
Using a for loop and range command, print the sequence of numbers from 1 to 20...
Using a for loop and range command, print the sequence of numbers from 1 to 20 (skipping two numbers for each element); that is, your code should print out the numbers 1,4, 7, 10, … (max should not exceed 20). Use x as the variable name
IN JAVA: Write code (using ArrayLists) to read a line of input from the user and...
IN JAVA: Write code (using ArrayLists) to read a line of input from the user and print the words of that line in sorted order, without removing duplicates. For example, the program output might look like the following: Type a message to sort: to be or not to be that is the question Your message sorted: be be is not or question that the to to
Write a script to display numbers from 1 to n, where n is an integer provided...
Write a script to display numbers from 1 to n, where n is an integer provided by users (if not, default to 10). Hint: use “read” command to accept user input. a) Display the source code in an editor (#4-9) b) Execute your script in the terminal, and display the command and the result (#4-10)
In C++ Please, Write a code fragment that uses a loop to calculate ln (i.e. natural...
In C++ Please, Write a code fragment that uses a loop to calculate ln (i.e. natural log), from values of ranging from ‘1’ through ‘10’ in steps of ‘1’. Print out in this format: Ln(1) = 0 Ln(2) = 0.6931 etc.
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter 10 numbers. 2. save those numbers in a 32-bit integer array. 3. Print the array with the same order it was entered. 3. Calculate the sum of the numbers and display it. 4. Calculate the mean of the array and display it. 5. Rotate the members in the array forward one position for 9 times. so the last rotation will display the array in...
(java) a. The following code has compilation AND logic errors. Rewrite the code (using the while...
(java) a. The following code has compilation AND logic errors. Rewrite the code (using the while loop) so it will compile correctly and print all the even numbers from 0 to 10 on one line separated by a space: int j = 0; while j > 10 ; j + 2; System.println(j, “ “); b.You want to print the values of integers a and b to an external file “test123.txt”, assigned to the PrintWriter variable output. Correct the following statements:...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider that your user might give you two of the same...
Use Matlab to calculate the probabilities in the following scenarios. Provide your code as well as...
Use Matlab to calculate the probabilities in the following scenarios. Provide your code as well as your answer. Hint: You will find the following Matlab functions useful: normcdf(), normrnd() (a) IQ tests are designed in such a way that the mean and standard deviation are equal to 100 and 15 respectively. What is the probability of having an IQ score of 130 or more? (b) What is the probability of having an IQ between 110 and 130? (c) Bolts for...
Assignment Content You recently graduated from college and are applying for a programming job that requires...
Assignment Content You recently graduated from college and are applying for a programming job that requires the understanding of loops in Python. The manager you are interviewing with has asked you to take an assessment to prove your programming knowledge. Below are the requirements for the programming skills test. In Python, create a program that meets the following requirements: Take two integers from the user. Save the lower number as x. Save the largest integer as y. Write a loop...
Manually calculate the mean, median, mode, and range of the BMI values. Show all of your...
Manually calculate the mean, median, mode, and range of the BMI values. Show all of your work. BMI values 24.0, 21.2, 21.4, 25.1, 21.9, 31.1, 22.3, 29.2, 20.7, 23.3, 31.8, 20.7, 27.5, 25.9, 20.8, 28.3, 22.3, 25.7, 24.0, 26.9, 22.5, 20.2, 24.0, 29.5, 33.5