+1(805) 568 7317

matlab we will expand on the while loop square root algorithm from the previous assi 5151300


We will expand on the while-loop square root algorithm from the previous assignment in two ways: 1. Run the algorithm for thr We will expand on the while-loop square root algorithm from the previous assignment in two ways: 1. Run the algorithm for three different N values. This will be accomplished with a for loop. 2. Record the approximations from every step, so we can plot the progress of the algorithm. In prior scripts, the guess scalar was overwritten each time through the loop. This time we have the guess_record matrix. It will have one row for each starting number listed in nums. And it will have as many columns as are needed to bring the numbers within tolerance Your final matrix should look like the results below. Notice how the top row represents the approximations for the square root of 121, eventually getting to 11. The last two columns read NaN; this is because they originally held zeros by default, but we converted them to NaN so as to not fill incorrect data onto the plot. 7 2 5 1 4 11.000 NaN NaN 11.0002 61 31.4918 176670 12.2580 110645 1 NalN 20.0662 20.000 20.0000 200.5000 101.2475 52.5991 30.1019 21.6950 2 50.6008 50.0036 50.0000 161.5271 88.5022 583750 12505e 03 626.2496 3151208 3 The values are filled in to the matrix with the following command. Each time through the while loop, only one particular index within guess_record has a new value entered in – guess ; guess_record (num_ind, n_its) Farameter nums 121; 400: 25001 toierance .00:1: t 11 lipie nunbers o ind equsre rot ef se tclerence hen do we p the lcop?) erforz aigorichn until withir tolerance n_rurs length (nus): for nun ind- 1: nur nuns (nun ind) guess-nun cempute he manyY ting uer are 1isted t through he algerth crce fer each atarting manber exract he urer starting vaite se iniel ues compute rea square root t zeset the auber cf iteration to zezo n ts-0 e ab guess n its n ita 1 cuess_record (nur ind,n_ run iteraicns until tolerace e euacion from algorithn increase t by 1 record curren ger cerzect ndex guess-real)>f wh cuess: end end t clea u the ges-reccrd abie by elininating zezos guess record (guess_record–)-NaN ke lct x0:sze (guess_record, 2): y nuns, guess record] 3ubplot (2,1,1) pio: (x, y) yiabel Approxination (linear)) x wll be recte helding , 1, 2,… t appand th ini alues to he approxiatione aubplot (2,1,2 senilogy (x,y) xlabel (Iteraicn ') yiabel ('Approxination (senilog)')

"Order a similar paper and get 15% discount on your first order with us
Use the following coupon

Order Now