How to remove elements from two arrays when one of them has a zero

조회 수: 1 (최근 30일)
Giuseppe D'Amico
Giuseppe D'Amico 2021년 3월 3일
댓글: Giuseppe D'Amico 2021년 3월 3일
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
Giuseppe D'Amico
Giuseppe D'Amico 2021년 3월 3일
How can I calculate the MAPE? If I divide the two arrays, I get a matrix

댓글을 달려면 로그인하십시오.

답변 (1개)

the cyclist
the cyclist 2021년 3월 3일
idx_to_remove = target_2019==0;
target_2019(idx_to_remove) = [];
output_2019(idx_to_remove) = [];

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by