How to choose only certain values my matrix answer

조회 수: 5 (최근 30일)
Krishma Gold
Krishma Gold 2019년 9월 12일
댓글: Krishma Gold 2019년 9월 14일
Hi. Grateful for any help please.
My output is in matrix, say 400 563 674 904 789
Now i want to use 563 to 904, as a matrix in another algorithm without me redefining it.
Many thanks

답변 (2개)

David Hill
David Hill 2019년 9월 12일
A=[400,563,674,904,789];
B=A(A>=563&A<=904);
  댓글 수: 3
David Hill
David Hill 2019년 9월 14일
My B above gives you that output. If you want a column vector just add an apostrophe.
A=[400,563,674,904,789];
B=A(A>=563&A<=904)';
Krishma Gold
Krishma Gold 2019년 9월 14일
thank you

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


Walter Roberson
Walter Roberson 2019년 9월 14일
A=[400,563,674,904,789];
idx1 = find(A>=563, 1, 'first');
idx2 = find(A>=904, 1, 'first');
A(idx1:idx2)
but I suspect what you might be looking for is:
A(2:end-1)
  댓글 수: 1
Krishma Gold
Krishma Gold 2019년 9월 14일
Thank you
you are right ....A(2:end-1).... works perfectly

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

카테고리

Help CenterFile Exchange에서 Pulsed Waveforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by