How to delete values using logical operator.

2 Ansichten (letzte 30 Tage)
Cory Sundquist
Cory Sundquist am 3 Mär. 2018
Kommentiert: Cory Sundquist am 3 Mär. 2018
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.

Akzeptierte Antwort

Ahmet Cecen
Ahmet Cecen am 3 Mär. 2018
Bearbeitet: Ahmet Cecen am 3 Mär. 2018
function f=test7()
clc;
r=[2 4 3 1 8 7 6 1 6 0];
r(r==4|r==6)=[];
f=r;
end

Weitere Antworten (0)

Kategorien

Mehr zu Entering Commands finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by