How to delete values using logical operator.

조회 수: 3 (최근 30일)
Cory Sundquist
Cory Sundquist 2018년 3월 3일
댓글: Cory Sundquist 2018년 3월 3일
Ok y'all I know what is wrong with my function, but I want to delete all the 4's and 6's in a vector r. Here is as close as I came...
function f=test7() clc; r=[2 4 3 1 8 7 6 1 6 0]; r(r==(4||6))=[]; f=r; endfunction
which of course just deletes all the ones. Answer away.

채택된 답변

Ahmet Cecen
Ahmet Cecen 2018년 3월 3일
편집: Ahmet Cecen 2018년 3월 3일
function f=test7()
clc;
r=[2 4 3 1 8 7 6 1 6 0];
r(r==4|r==6)=[];
f=r;
end

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by