Hello everybody! My name is Roberto and I'm totally new with MATLAB which I'm now using for the first time in my econometric's class. I was asked to resolve this exercise: " 1) Generate 10000 normally distributed (0,1) observation X " 2) Compute the fraction of observed values above 1.95 or below -1.95.
While first point I haven't had any kind of problems, I found some in writing the looping code for the second point of the exercise. In particular, what I wrote is:
x=randn(10000,1)for i=-1.95:1.95if x(i,1)>=1.95 | x(i,1)<=-1.95 x(i,1)=1else y(i,1)=2endend
When I execute the code, MATLAB returns me the error:
"Attempted to access x(-1.95,1); index must be a positive integer or logical."
As I said before, I'm totally new to the world of MATLAB and its programming code. I really hope you can help me with this absolutely stupid problem.
Best Answer