find value every time counter increase by 2.
Mostra commenti meno recenti
hello community kindly let me ask your support:
I have 2 vectors:
a = [0 0 0 0 1 1 2 2 3 3 3 3 4]'; %Counter
b = [0 1 2 3 4 5 6 7 8 9 10 11 12]'; %value to be found
c = [0 0 0 0 0 1 1 0 0 0 0 0 1]'; %flag when condition is met
what I'm trying to do is to get a value from b every time a increases its value by 2 and when c = 1
for j=1:length(time)
if a(j) == a(j) ++2 && c == 1
d(j,1) = b(j);
end
I'm trying to get something like:
d = [ 0 0 0 0 0 0 6 0 0 0 0 12]
can not find the solution......
any advice will be highly appreciated.
2 Commenti
John D'Errico
il 8 Mar 2024
Your example does not match what you asked.
a = [0 0 0 0 1 1 2 2 3 3 3 3 4]
a NEVER increases its value by 2 from the previous element in that vector.
Are you asking to find when a has increased by 2 from the previous case you found? So there the 6th element is 2 greater than 0, the start of the vector. But what are you asking?
A-Rod
il 8 Mar 2024
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!