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)
Show older comments
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.
0 Comments
Answers (1)
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;
0 Comments
See Also
Categories
Find more on MATLAB Report Generator in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!