フィルターのクリア

Indexing within two for loops where the index can be below zero

2 ビュー (過去 30 日間)
Natialol
Natialol 2013 年 6 月 3 日
Hello,
How do I index within two for loops, see example below. I am running a script (quet) recursively and the output is a 1 by n vector.
for ab=0:1:16
for bc=0:1:16
abc=quet(ab,bc);
Ptr(A)=[abc,ab,bc];
end
end
This replaces Ptr(A) each time, I cannot use a matrix as the output of quet is a 1 by n vector, and I cannot use an array as the index contain zero. Ideally I would like to store the output in an array (ab,ab,bc) Thanks

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 3 日
Ptr=[]
for ab=0:1:16
for bc=0:1:16
abc=quet(ab,bc);
Ptr(end+1,:)=[abc,ab,bc];
end
end
  3 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 3 日
what are sizes of ab and bc?
Natialol
Natialol 2013 年 6 月 3 日
ab and bc are scalar values. abc is 1 by n vector.

サインインしてコメントする。

その他の回答 (1 件)

Iain
Iain 2013 年 6 月 3 日
list1 = 0:1:16;
list2 = 0:0.5:8;
list3 = -45:1.23:45;
c = 0;
for i = 1:numel(list1)
val1 = list1(i);
for j = 1:numel(list2)
val2 = list2(j);
for k = 1:numel(list3)
c = c + 1;
val3 = lst3(k);
Output1(i,j,k) = somethign;
Output2(c) = somethingelse;
end
end
end
Expand as needed ;)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by