I have a question about the way to extract some data from a cell based on some "indices" (in this case I want only to get as an output the "1-associated" values, e.g.:
A={'a' 'b' 'c'; 'd' 'e' 'f';'g' 'h' 'i'}
B=eye(3);
...formula to compare the arrays....
C={'a' '0' '0'; '0' 'e' '0';'0' '0' 'i'}
or
C={'a' nan nan; nan 'e' nan;nan nan 'i'}
I really cannot see the way to easily do it. Thanks

 채택된 답변

추가 답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 4월 8일

0 개 추천

[A{~B}] = deal('0');

댓글 수: 1

A simpler version of this idea is
A(~B) = {'0'}
Caution: this solution overwrites A itself, which you may not want.

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

카테고리

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

태그

질문:

2020년 4월 8일

댓글:

2020년 4월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by