Hello,
I am wondering if anyone can give me any pointers on a topic.
I have a logical vector of true false the same number of rows as my raw matrix.
The raw matrix, I would like to index for the rows that that are true in my logical vector.
The raw matrix is in cell format though and is a big mash of numerical and written data so I can't seem to convert it to another form.
Is there a way for me to pull the rows i'm interested in from this matrix?
Thanks for any help/advice/direction

 채택된 답변

Thorsten
Thorsten 2015년 10월 7일

0 개 추천

Xnew = X(ind, :);

댓글 수: 3

Chameleon17
Chameleon17 2015년 10월 7일
편집: Stephen23 2015년 10월 7일
Thank you very much,
I had tried that already but I get an error message: Subscript indices must either be real positive integers or logicals.
Which I do not understand as the vector I'm using as ind is 1's and 0's?
I think I'm missing something very simple.
Thorsten
Thorsten 2015년 10월 7일
편집: Thorsten 2015년 10월 7일
If it is not logical you have to convert it to logical using
Xnew = X(logical(ind), :);
As help logical reveals,
Because logical arrays are returned by the logical operators (&,|,~)
and the relational operators (==,~=,<,<=,>=,>), as well as by
functions like ANY, ALL, ISNAN, ISINF, ISFINITE, ISEMPTY, ISEQUAL,
etc., it is unusual to need to invoke the logical function itself.
So presumably you have obtained your index by some other operations or did some numerical operation on it, (like minus), which caused Matlab to convert to double.
Ah! Yes, thank you, sigh, I should have noticed that.
Thank you! :)

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2015년 10월 7일

편집:

2015년 10월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by