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?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
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.
Answers (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!
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!