# I have been told my answer to this matlab question is wrong

Printable View

• Feb 8th 2010, 10:49 AM
adam_leeds
I have been told my answer to this matlab question is wrong
I have got to create a set of n = 51 points on a grid L(h,x0), characterize by the parameters h = 1 and x0=0, where the second co-ordinate is given by the expression

f(x) =sin(x) + eta*0.1

where -1< eta < 1 is a random deviate (use the function rand to generate such a deviate).

This is what i have done but i have been told it is wrong, have i answered the question?

x = 0:1:50;
eta = 2*rand(size(x))-1;
y = sin(x) + (eta*0.1)

Im not sure if i have done the grid right, i guessed it meant start at 0 and go up 1, 51 times.

Thanks for your help in advance.
• Feb 9th 2010, 04:29 AM
CaptainBlack
Quote:

Originally Posted by adam_leeds
I have got to create a set of n = 51 points on a grid L(h,x0), characterize by the parameters h = 1 and x0=0, where the second co-ordinate is given by the expression

f(x) =sin(x) + eta*0.1

where -1< eta < 1 is a random deviate (use the function rand to generate such a deviate).

This is what i have done but i have been told it is wrong, have i answered the question?

x = 0:1:50;
eta = 2*rand(size(x))-1;
y = sin(x) + (eta*0.1)

Im not sure if i have done the grid right, i guessed it meant start at 0 and go up 1, 51 times.

Thanks for your help in advance.

The wording of your question is unclear, as far as I can see your code could be a realisation of what you have been asked for. Please post the original question with its exact wording.

CB