I have a vector A consisting of 200 elements, and I need to create new vectors made of elements of A that are bigger than a particular threshold but I need these new vectors to be named different from each other as to carry some procedure on them.
1 回表示 (過去 30 日間)
古いコメントを表示
I have a vector A consisting of 200 elements, and I need to create new vectors made of elements of A that are bigger than a particular threshold but I need these new vectors to be named different from each other as to carry some procedure on them.
0 件のコメント
回答 (2 件)
Azzi Abdelmalek
2016 年 4 月 5 日
A=[ 1 4 58 8 10]
B=A(A>4)
5 件のコメント
James Tursa
2016 年 4 月 5 日
It is not working because A(i) is presumably a scalar (you don't define A) but the result of Z(Z>Z(i)) is in general a vector. If you use cell arrays per my advice below you could do this:
A = cell(10,1);
for i=1:10;
A{i} =Z(Z>Z(i));
end
Then downstream you can access A{i} in a loop easily.
Azzi Abdelmalek
2016 年 4 月 5 日
Z=[6 7 8 5 6 7 8 3 2 4]'
A=cell(size(Z));
for i=1:10;
A{i} =Z(Z>Z(i));
end
celldisp(A)
James Tursa
2016 年 4 月 5 日
Don't do that. Use cell arrays instead, which are much easier to maintain and access in a loop. See this link:
0 件のコメント
参考
カテゴリ
Help Center および 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!