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 view (last 30 days)
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.

Answers (1)

Ameer Hamza
Ameer Hamza on 30 May 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;

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!