How to correct the below code?

7 visualizzazioni (ultimi 30 giorni)
satish bhat
satish bhat il 14 Ago 2016
Risposto: John BG il 14 Ago 2016
n=5; p=4;
u=randn(n, p);
X= sqrt(1-r*r)*u + r*u;
e=normrnd(0*eye(n),5*(n))
beta0=[4;3;2.3;1];
y=X*beta0*(eye(n))'+e;
  1 Commento
the cyclist
the cyclist il 14 Ago 2016
The code won't run because the value of r is not defined.

Accedi per commentare.

Risposta accettata

John BG
John BG il 14 Ago 2016
Satish
change your last line from
y=X*beta0*(eye(n))'+e;
to
diag(X*beta0)+e
I assumed
r=1
the command diag does what you tried with eye(n).
Satish
would you please be so kind to mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John BG

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by