How can I write a function that replaces all of the multiples of eight or nine in a vector with seven, unless the multiple of eight or nine is also a multiple of seven.

1 vue (au cours des 30 derniers jours)
How can I write a function that replaces all of the multiples of eight or nine in a vector with seven, unless the multiple of eight or nine is also a multiple of seven.

Réponses (1)

Ameer Hamza
Ameer Hamza le 30 Mai 2020
Something like this
x = 1:1000;
mul7 = mod(x, 7)==0;
mul8 = mod(x, 8)==0;
mul9 = mod(x, 9)==0;
mask = (mul8 | mul9) & (~mul7);
x(mask) = 7;

Catégories

En savoir plus sur MATLAB Report Generator dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by