Hello
I am trying to compare two arrays and the save the results in a new one (third), the first array is 1000x1 double array and the second array is 1000x1 logical array. I'd like to compare them to each other, meaning for every true value (1) in the logical array I'd get the corresponding value of the double array (first array) saved in the new array (third array).
How can I do that? I tried looking up for that on the " Relational Operations" but I could'nt find something relevant, Should I do an if condition statement and how?

 채택된 답변

Walter Roberson
Walter Roberson 2021년 8월 9일

0 개 추천

result = DoubleArray(LogicalArray);
Logical indexing.

댓글 수: 1

worked like a charm, I didn't expect it to be this simple
Thanks

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

추가 답변 (0개)

카테고리

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

제품

릴리스

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by