Azzera filtri
Azzera filtri

For Loop

1 visualizzazione (ultimi 30 giorni)
Lu
Lu il 30 Mag 2012
Hi everybody!!
I´m trying to do a simple loop that looks like this:
for t = 1 : 1 : 5
[k_hat, b_T, values] = E_Test(y(t:1800+t-1), n_0);
a(:)=k_hat(t);
end
I just want that for every t, the variable "a" stores the variable k_hat but it is not working. I get the following error: Attempted to access k_hat(2); index out of bounds because numel(k_hat)=1.
If instead I try a(t)=k_hat; it just gives me one value of k_hat instead of 5 values. Could you please give me a hint on what am I doing wrong here?
Thank you so much!

Risposta accettata

Honglei Chen
Honglei Chen il 30 Mag 2012
Apparently your k_hat is a scalar. It is probably changing in each iteration because the t you passed into E_Test is different. You can try the following in the loop
[k_hat(t), b_T, values] = E_Test(y(t:1800+t-1), n_0);

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by