Write your program so that it can handle an array as input


Write a MATLAB program that receives as input a number x and a parameter n and returns x rounded to n decimal digits. Write your program so that it can handle an array as input, returning an array of the same size in this case. Use your program to generate numbers for Example 2.2, demonstrating the phenomenon depicted there without use of single precision.

Example 2.2

We evaluate g(t) = e-t (sin(2πt)+2) at 501 equidistant points between 0 and 1, using the usual double precision as well as single precision and plotting the differences. This essentially gives the rounding error in the less accurate single precision evaluations. The following MATLAB instructions do the job:

2176_20cab1ae-9d39-4c64-90dd-cffbe4802705.png

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Write your program so that it can handle an array as input
Reference No:- TGS01666477

Expected delivery within 24 Hours