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.
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:
Get Answers For Free
Most questions answered within 1 hours.