필터 지우기
필터 지우기

Trying to find the min non-zero value of a [925x902] matrix

조회 수: 4 (최근 30일)
Todd Pierce
Todd Pierce 2022년 4월 25일
댓글: Star Strider 2022년 4월 25일
I am trying to find the minimum non-zero value of a [925x902] matrix called D1.Z
i have tried:
min(D1.Z(D1.Z > 0));
D1.Z(D1.Z==0) = nan; then min(min(D1.Z));
Error comes up saying the 'index exceeds the number of array elements (1)'
Anyway around these?

채택된 답변

Star Strider
Star Strider 2022년 4월 25일
Perhaps —
D1.Z = rand(925,902) % Create Test Matrix
D1 = struct with fields:
Z: [925×902 double]
D1.Z(randi(numel(D1.Z),1,5)) = 0; % Set Some Elements To Zero
Check = min(D1.Z,[],'all') % Check Matrix To Demonstrate Replacement Effective
Check = 0
MinZ = min(D1.Z(D1.Z~=0),[],'all') % Return Minimum ~= 0
MinZ = 1.2686e-06
.
  댓글 수: 6
Star Strider
Star Strider 2022년 4월 25일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by