Calculate frequency for each gridded

1 Ansicht (letzte 30 Tage)
Nurul Ain Basirah Zakaria
Nurul Ain Basirah Zakaria am 2 Apr. 2021
Hi. Is it possible that I want to,
Change the value of -1.00 untill -3.00 tu 1 and the rest as 0. Then, I want to know how much 1 in each grid, how can I calculate how much amount of 1?

Akzeptierte Antwort

KSSV
KSSV am 2 Apr. 2021
Let A be your matrix/ grid.
idx = A<-1 & A>-3 ;
A(idx) = 1 ;
A(~idx) = 0 ;
nnz(A==1)
nnz(A==0)
  5 Kommentare
KSSV
KSSV am 2 Apr. 2021
yes = 0 ; no = 0 ;
for i=1:5
for j=1:11
if idx(i,j)==1
yes = yes+1 ;
elseif idx(i,j) == 0
no = no+1 ;
end
end
end
Nurul Ain Basirah Zakaria
Nurul Ain Basirah Zakaria am 7 Apr. 2021
sir, thank you very much. i will try to understand looping better

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by