Replace values of matrix by multiples
Mostra commenti meno recenti
Write the instruction that replaces the values of A that are multiples of 10 by 999
I got this so far: A=A(mod(10,999)==0)
Im not sure of it though.
4 Commenti
James Tursa
il 5 Apr 2020
Try doing just the first part. Does the expression mod(10,999) determine if anything is a multiple of 10?
Mansour Al Asais
il 5 Apr 2020
the cyclist
il 5 Apr 2020
Modificato: the cyclist
il 5 Apr 2020
Think of this as a two-step problem:
- identify the entries that are multiples of 10
- replace those with 999
You don't need to use the value 999 at all for the first part.
You are on the right track in using the mod function. But remember you that you are trying to find elements of A that are even multiples of 10. So, think of how to use A and 10 as your inputs.
Mansour Al Asais
il 7 Apr 2020
Risposte (1)
David Hill
il 7 Apr 2020
A(mod(A,10)==0)=999;
Categorie
Scopri di più su Library Development in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!