help with storing i,j loop results?
Afficher commentaires plus anciens
the following code,i use it to calculate a statistic. note:the statistic is (AIC) used in regression rand time series identification the first for loop i stored all result as
A 1 2 3 4 5
B 12 17 6 13 8
not A is ind and B is aic result BUT the second for loop i don't know how to get results as i did in the previous loop
i want store all the loop results taking in account that the ind (index) in second loop is (i,j)
for i=1:5
a=i;
ind=[a]
one=x(:,[i])
[b_LS, sigma_b_LS, s_LS] = lscov(one,y)
s = s_LS
aicx1=size(one,1)*log(s)+2*size(one,2)
A(i)=vertcat(ind)
B(i)=vertcat(aicx1)
end
aic1=[A;B]
m=[]
for i=1:4
for j=2:5
if i<j
a=i;
b=j;
ind=[a,b]
two=x(:,[i,j])
[b_LS, sigma_b_LS, s_LS] = lscov(two,y)
s = s_LS
aicx2=size(two,1)*log(s)+2*size(two,2)
end
end
end
what can i do? Thanks
1 commentaire
Stephen23
le 21 Déc 2014
Do not use i or j for your loop variables, as these are the names of the inbuilt imaginary unit . Shadowing the standard functions and variables like this is usually a bad idea.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!