Changing values in 2D array using logical operators

조회 수: 3 (최근 30일)
Bob
Bob 2012년 7월 18일
I'm sure I've solved this before, but it's befuddled me today.
I have a 2D array and I want to subselect some values and set them to nan:
aa=rand(10,10);
ab(aa<0.5)=nan;
ab is now a 1x100 row vector - how can I perform the operation but maintain the 2D array?

채택된 답변

Sebastian Holmqvist
Sebastian Holmqvist 2012년 7월 18일
aa = rand(10, 10);
aa(aa < 0.5) = NaN;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by