Borrar filtros
Borrar filtros

How to state that at least 80% of the values in my vector need to be positive

2 visualizaciones (últimos 30 días)
Hi, I have data with 10 frames per second and 180 seconds, which leaves me with a row vector of 1800 values, which can be positive or negative.
If all the values are negative, it needs to say "no positive values". If all the values are positive, it needs to say "no negative values".
if there are both negative and positive values then I want to find out if, after the first 15 seconds (so after first 150 values in my vector), atleast 80% of those values are positive. If yes, then I want to find the index of the first postive value. If no, then it needs to say "less than 80% positive"

Respuestas (1)

Guillaume
Guillaume el 12 de Jul. de 2019
if mean(yourvector(150:end) > 0) >= 0.8 %assuming positive means strictly greater than 0
startindex = find(yourvector(150:end) > 0, 1) + 149;
else
disp('less than 80% positive')
end
  1 comentario
Image Analyst
Image Analyst el 12 de Jul. de 2019
Building...
if max(yourvector) < 0
fprintf('Failed: No positive values were found! (All were negative)\n');
elseif min(yourvector) >= 0
fprintf('Success: No values are negative. (All are zero or positive).\n');
end

Iniciar sesión para comentar.

Categorías

Más información sobre Clocks and Timers en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by