loop error
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
x=[1.1 2.4 3.1 4.8 5.9 6.2 7.9 8.9 9.7 10.3 11.2 12.6 13.7 14.2 15.9 16.8 17.0 18.5 19.6 20.3 21.7 22.6 23.8 24.7 25.9 26.1 27.8 28.9 29.4 30.6 31.7 32.1 33.5 34.1 35.2 36.9 37.8];
n = length(x);
L = floor(n/5);
N = n;
for a=1:N-L*4;
T=cell(a,L);
for jj = 1:L;
S = jj;
n = zeros(1,floor((N-a)/(S))+1);
for ii = 1:length(n)
n(ii) = x(S*(ii)+(a-S));
end
T{a,jj} = n;
end
end
I have this code to get data from x. 'a' is the start number, I want to do a loop like 'for a=1:N-L*4',but the answer is only when a=N-L*4, there is no a=1,a=2,... What's wrong with my loop?
0 Kommentare
Akzeptierte Antwort
Andrew Newell
am 28 Mär. 2011
You're creating T on each iteration of the loop. Remove
T = cell(a,L);
and put
T = cell(N-L*4,L);
above for a=1:N-L*4.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Communications Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!