Determine percent of array elements which meet condition
43 views (last 30 days)
Star Strider on 20 Jul 2021
A logical array has two states, true=1 or false=0, so al that is necessary is to find the numbers of 1 values with respect to the total number of elements.
TF = randi([0 1], 25) == 1; % Create Array
T = nnz(TF) % Number Of 'true' Values
T_Pct = 100*T/numel(TF) % Percent 'true' Values