Removing a row from a matrix when one value is zero without hardcoding

조회 수: 3 (최근 30일)
James Keiser
James Keiser 2021년 6월 15일
댓글: James Keiser 2021년 6월 15일
You have been provided stock data for Boeing in 2018 (from January 1st to December 31st). The data includes the opening (column 4) and closing values (column 7) for the day, along with the highest (column 5) and lowest value (column 6) for the day. I need to be able to remove the rows where opening = 0 without hardcoding.
Code:
Opening = BoeingStock(:,4);
if Opening == 0
BoeingStock(:) = []
else
BoeingStock(:,:0 = [:,:]
end

답변 (1개)

Mouhamed Niasse
Mouhamed Niasse 2021년 6월 15일
Hello,
Here is what i achieved.
Hope it does help you.
BoeingStock(BoeingStock(:,4)==0,:)=[]

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by