I want to check the list [2:N] for values that are devisible by 2 and remove those from the list, help plz
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Catalytic Kys
il 2 Dic 2019
Commentato: Catalytic Kys
il 2 Dic 2019
clear;
close all
clc;
N = 10
list = [2:N]
x = 2
if (list(list(x) ~= 2) == 'false'
list(x) = []
x = x + 1
end
0 Commenti
Risposta accettata
KALYAN ACHARJYA
il 2 Dic 2019
Modificato: KALYAN ACHARJYA
il 2 Dic 2019
N = 10;
list=2:N
list(find(mod(list,2)==0))=[]
Result:
list =
2 3 4 5 6 7 8 9 10
list =
3 5 7 9
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Encryption / Cryptography in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!