loop error

조회 수: 9 (최근 30일)
Tian Lin
Tian Lin 2011년 3월 28일
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일
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.
  댓글 수: 1
Tian Lin
Tian Lin 2011년 3월 29일
it works!thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Communications Toolbox에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by