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?

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.

Respuestas (1)

Adam
Adam el 27 de Mzo. de 2015
Editada: Adam el 27 de Mzo. de 2015
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!

La pregunta está cerrada.

Etiquetas

Preguntada:

el 27 de Mzo. de 2015

Cerrada:

el 20 de Ag. de 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by