I will appreciate any suggestion on this simple code. I want to substitute the elements of x >5 with 6 and x<5 with zero.
Afficher commentaires plus anciens
for j=1:1:8
x=[1 2 3 4 5 6 7 8];
if x(j)>5
x(j)=subs(x(j),x(j),6);
else
x(j)=subs(x(j),x(j),0);
end
end
Réponse acceptée
Plus de réponses (1)
matico
le 16 Août 2015
Also:
x=[1 2 3 4 5 6 7 8];
x(x>5) = 6;
x(x<=5) = 0;
Catégories
En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!