MATLAB Q8 The following code is a simple guessing game while

MATLAB

Q8. The following code is a simple guessing game: while 1 x = rand(1); The Quality of a Curve Fit The least-squares criterion used to t a function x) is the sum of the squares of the residuals J. de ned as 62-1) n = input(\'Enter an integer from 0 to 10: \') ; if(n-round(n)-= 0 & n = 0 & abs(n-y)

Solution

8)

Solution :

The code runs as follows :

while 1 : sets the prompt in infinite loop . (so that you can have many input cases)

x = rand(1) ; %generates random number between 0 to 1 . say 0.5 for example.

y = x*7   % scales above value of x from 0 to 7 . i.e when x=0 y= 0 and when x=1 , y =7 then 7x = 3.5

if (....) % this line cheks for the input n taken from command prompt is lying in the interval [0 7]

and if close to the y by margin of 0.5 . ( so if you provide input in the range 3 to 4 , you win in this case)

hence basically we win whenever we guess the input n close to y by 0.5 .

So this guess has to be in the interval to in the range of [0 7]

So option a is the answer.

11)

assuming the 13th sample of y is generated after curve fitting we have control over the coefficients of fitting.

hence we can predict fitting at 13th sample so its still random value.

hence answer is :

option e.

MATLAB Q8. The following code is a simple guessing game: while 1 x = rand(1); The Quality of a Curve Fit The least-squares criterion used to t a function x) is

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site