Given a positive integer n which is not a perfect square, write a MATLAB script that will calculate the square root of n truncated to k places after the decimal point. Your output should be a string. For example, the output of string_sqrt(1000,10) should be '31.6227766016' Notice that the square root of 1000 is (according to MATLAB) 31.62277660168379, so we want the integer part complete, as well as the first k numbers after the decimal point without rounding.
Several of the values of k will be larger than the usual precision shown by MATLAB, so you'll need to be inventive. Good luck.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers32
Suggested Problems
-
Arrange Vector in descending order
13263 Solvers
-
Cell Counting: How Many Draws?
2384 Solvers
-
Find the sides of an isosceles triangle when given its area and height from its base to apex
2140 Solvers
-
String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values
1964 Solvers
-
Find the Oldest Person in a Room
20286 Solvers
More from this Author80
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!