Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Need help to calculate this

1 Ansicht (letzte 30 Tage)
Ricardas Gudonavicius
Ricardas Gudonavicius am 21 Mär. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hello.
First of all, I have binary array, for example f = (1, 1, 1, 1, 0, 0, 0, 0). In my array there is no numbers lined up like this f = (1,0,1,1,0,1).
This is my code:
kiek = 0;
taskas = 0;
tarpas = 0;
bruksnys = 0;
for i = 2:length(f)
if f(i-1) == 1 && f(i) ~= 0
kiek = kiek + 1;
if kiek == 3000
taskas = taskas + 1;
end
if kiek == 13000
bruksnys = bruksnys + 1;
end
end
if f(i) == 0
kiek = 0;
end
end
When I run the code I get aswers like this:
bruksnys = 4
taskas = 15
The problem is that I have to get answer:
bruksnys = 4
taskas = 11
It's allways add up but I don't know how provent from this
Can somebody help me.
  4 Kommentare
Ricardas Gudonavicius
Ricardas Gudonavicius am 21 Mär. 2020
Bearbeitet: Ricardas Gudonavicius am 21 Mär. 2020
You see I have big array. The size is 216422.
I want to count how many I have ones or it is 3000 or it is 13000. But I allways count them together.
I mean together for taskas i count 3000 and 13000 ones, when i need them to count separately
Ricardas Gudonavicius
Ricardas Gudonavicius am 21 Mär. 2020
By coping code made mistake range command should not be

Antworten (0)

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by