How do I replace Matrix elements
    12 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    Liam Bouchereau
 le 27 Oct 2020
  
    
    
    
    
    Modifié(e) : Stephen23
      
      
 le 27 Oct 2020
            Given a matrix A replace elements not equal 0 and not equal 1 by 5. Use disp() function to print out the resulting array.
So far I've got 
A(A~=0) = 5;
disp(A);
but do not know how to make it 0 AND 1.
2 commentaires
  KSSV
      
      
 le 27 Oct 2020
				When you use  ~=0 and replace those with 5, the elements whch have 1 also will be eplaced by 5 right? 
Réponse acceptée
  Sudhakar Shinde
      
 le 27 Oct 2020
        
      Modifié(e) : Sudhakar Shinde
      
 le 27 Oct 2020
  
      Try this:
A((A>1)|(A<0))=5
5 commentaires
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!