Change input user 0 to -1

1 Ansicht (letzte 30 Tage)
Soveatin Kuntur
Soveatin Kuntur am 10 Mai 2021
Kommentiert: Soveatin Kuntur am 10 Mai 2021
I want to make some program which required input from user. I want to make the program works this way
for example if user input : x = [1 1 1; 0 1 1; 0 0 0; 1 1 0;] then matlab will automatically change it into x = [1 1 1; -1 1 1; -1 -1 -1; 1 1 -1;] before processing it to some formula

Akzeptierte Antwort

David Fletcher
David Fletcher am 10 Mai 2021
x = [1 1 1; 0 1 1; 0 0 0; 1 1 0;]
x(x==0)=-1
  1 Kommentar
Soveatin Kuntur
Soveatin Kuntur am 10 Mai 2021
Thanks dave!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by