loop error

5 ビュー (過去 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 Center および File ExchangeCommunications Toolbox についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by