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
use MATLAB !!!!!1Must answer 2 and 3 together. use MATLAB code only in the simplest term...
use MATLAB !!!!!1Must answer 2 and 3 together. use MATLAB code only in the simplest term 2.Prompt the user to enter an array of numbers. Use the length function to determine how many values were entered, and use disp function to report your results to the command Window. 3.Repeat Exercise 2, and use fprintf to report your results.
Instructions Write a Java code Your goal is to take N integer inputs from the user...
Instructions Write a Java code Your goal is to take N integer inputs from the user -- N's value will be given by the user as well. You can assume the user provides a valid value for N, i.e., >0. Store the input integers in an array of size N in the order they are provided. These tasks should be done in the main() method. Create a new method called checkArray() that will take the previously created array as input...
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
Using Python: Create a code to generate 1001 values between 0 and 10 (essentially, start from...
Using Python: Create a code to generate 1001 values between 0 and 10 (essentially, start from 0 and use increment 0.01) and for each value ? ∈ [0,10] calculate sin(?) and the derivative of ?(x) = sin(?) using the central difference method: ????(?)/?? = ?(?+0.01)−?(?−0.01) 2∙0.01 . Output the result in a file using the print command: print (?, ???(?) , ????(?), ??? =′ ′, ??? =′\ ? ′ , ???? = ??) Recall that the output file must be...
Write a java code that allows the user to input any name (up to 10 only)...
Write a java code that allows the user to input any name (up to 10 only) and then sorts and alphabetizes them in an array without using predefined methods (.compareTo(), or any sorter functions) and then print out the results.
Write a program that takes n integer numbers from the user, and then counts the number...
Write a program that takes n integer numbers from the user, and then counts the number of even numbers and odd numbers and print them to the screen. Sample Output: Enter how many numbers you have: 10 Enter the 10 numbers: 1 3 19 50 4 10 75 20 68 100 The number of even numbers is: 6 The number of odd numbers is: 4 (( in java ))
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)
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for...
Using MATLAB or Octave, use documenting code to Write a script that prompts the user for a non-negative integer value a. The script should then evaluates the sum Pn i=1 i a using a running sum for the case when n = 5. More specifically, use a counter for i that is used in the output fprintf as well as in the running sum. Feel free to write some code and just repeat it 5 times in your script. Sample...
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.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT