Effacer les filtres
Effacer les filtres

For Loop

1 vue (au cours des 30 derniers jours)
Lu
Lu le 30 Mai 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!

Réponse acceptée

Honglei Chen
Honglei Chen le 30 Mai 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);

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by