loop error

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?

 采纳的回答

Andrew Newell
Andrew Newell 2011-3-28

0 个投票

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.

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

标签

Community Treasure Hunt

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

Start Hunting!

Translated by