필터 지우기
필터 지우기

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.

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 4월 5일
A=[ 1 4 58 8 10]
B=A(A>4)
  댓글 수: 5
James Tursa
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.

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


James Tursa
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:

카테고리

Help CenterFile 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