How can I create a program that allows the user to enter a matrix of any size and replaces only the negative values in the matrix with -100?
Infos
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Afficher commentaires plus anciens
Im a beginner at matlab and I can't solve this simple problem. I know a forloop is involved but I am still unsure how to do this.
Réponses (1)
x( x < 0 ) = -100;
will replace negative values of x with -100. Allowing a user to create a matrix depends how you want to do it. Either a GUI or just on command line.
For loops shouldn't be anywhere near this problem though!
Cette question est clôturée.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!