How to remove elements from two arrays when one of them has a zero
Mostra commenti meno recenti
Hi everyone, I'll explain my problem.
I have two arrays of the same length which are called respectively: target_2019 and output_2019, what I am going to do is the difference between these two arrays and I calculate the MAPE. However, some of the values present in target_2019 are zeros, how can I eliminate these zeros by simultaneously eliminating the measure that corresponds to this zero in the output_2019 array?
I hope I was clear.
Would anyone know how to help me?
3 Commenti
Konrad
il 3 Mar 2021
keepme = target_2019~=0;
target_2019 = target_2019(keepme);
output_2019 = output_2019(keepme);
Giuseppe D'Amico
il 3 Mar 2021
Giuseppe D'Amico
il 3 Mar 2021
Risposte (1)
the cyclist
il 3 Mar 2021
idx_to_remove = target_2019==0;
target_2019(idx_to_remove) = [];
output_2019(idx_to_remove) = [];
Categorie
Scopri di più su Logical 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!