Cody

# Problem 3103. Find out Harmonic mean.

Solution 1965735

Submitted on 7 Oct 2019 by Shivam Gupta
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
x = 1:10; y_correct = 3.4142; assert(abs(h_mean(x)-y_correct)<0.0001)

res = 1 res = 1.5000 res = 1.8333 res = 2.0833 res = 2.2833 res = 2.4500 res = 2.5929 res = 2.7179 res = 2.8290 res = 2.9290

2   Pass
x = 1:5; y_correct = 2.1898; assert(abs(h_mean(x)-y_correct)<0.0001)

res = 1 res = 1.5000 res = 1.8333 res = 2.0833 res = 2.2833

3   Pass
x = 10; y_correct = 10; assert(abs(h_mean(x)-y_correct)<0.0001)

res = 0.1000

4   Pass
x = 1:50; y_correct = 11.1131; assert(abs(h_mean(x)-y_correct)<0.0001)

res = 1 res = 1.5000 res = 1.8333 res = 2.0833 res = 2.2833 res = 2.4500 res = 2.5929 res = 2.7179 res = 2.8290 res = 2.9290 res = 3.0199 res = 3.1032 res = 3.1801 res = 3.2516 res = 3.3182 res = 3.3807 res = 3.4396 res = 3.4951 res = 3.5477 res = 3.5977 res = 3.6454 res = 3.6908 res = 3.7343 res = 3.7760 res = 3.8160 res = 3.8544 res = 3.8915 res = 3.9272 res = 3.9617 res = 3.9950 res = 4.0272 res = 4.0585 res = 4.0888 res = 4.1182 res = 4.1468 res = 4.1746 res = 4.2016 res = 4.2279 res = 4.2535 res = 4.2785 res = 4.3029 res = 4.3267 res = 4.3500 res = 4.3727 res = 4.3949 res = 4.4167 res = 4.4380 res = 4.4588 res = 4.4792 res = 4.4992

5   Pass
x = 1:100; y_correct = 19.2776; assert(abs(h_mean(x)-y_correct)<0.0001)

res = 1 res = 1.5000 res = 1.8333 res = 2.0833 res = 2.2833 res = 2.4500 res = 2.5929 res = 2.7179 res = 2.8290 res = 2.9290 res = 3.0199 res = 3.1032 res = 3.1801 res = 3.2516 res = 3.3182 res = 3.3807 res = 3.4396 res = 3.4951 res = 3.5477 res = 3.5977 res = 3.6454 res = 3.6908 res = 3.7343 res = 3.7760 res = 3.8160 res = 3.8544 res = 3.8915 res = 3.9272 res = 3.9617 res = 3.9950 res = 4.0272 res = 4.0585 res = 4.0888 res = 4.1182 res = 4.1468 res = 4.1746 res = 4.2016 res = 4.2279 res = 4.2535 res = 4.2785 res = 4.3029 res = 4.3267 res = 4.3500 res = 4.3727 res = 4.3949 res = 4.4167 res = 4.4380 res = 4.4588 res = 4.4792 res = 4.4992 res = 4.5188 res = 4.5380 res = 4.5569 res = 4.5754 res = 4.5936 res = 4.6115 res = 4.6290 res = 4.6463 res = 4.6632 res = 4.6799 res = 4.6963 res = 4.7124 res = 4.7283 res = 4.7439 res = 4.7593 res = 4.7744 res = 4.7894 res = 4.8041 res = 4.8186 res = 4.8328 res = 4.8469 res = 4.8608 res = 4.8745 res = 4.8880 res = 4.9014 res = 4.9145 res = 4.9275 res = 4.9403 res = 4.9530 res = 4.9655 res = 4.9778 res = 4.9900 res = 5.0021 res = 5.0140 res = 5.0257 res = 5.0374 res = 5.0489 res = 5.0602 res = 5.0715 res = 5.0826 res = 5.0936 res = 5.1044 res = 5.1152 res = 5.1258 res = 5.1363 res = 5.1468 res = 5.1571 res = 5.1673 res = 5.1774 res = 5.1874

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!