Running an if function

1 Ansicht (letzte 30 Tage)
AA
AA am 21 Jan. 2015
Kommentiert: Geoff Hayes am 21 Jan. 2015
Hi, I want to run an If function. So if x<3 then I want function "Runningwater" to be executed. How can I implement this as code?
thanks guys

Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 21 Jan. 2015
AA - conditional control with an if, see flow control for details, can be written as
if x < 3
Running water;
end
  2 Kommentare
AA
AA am 21 Jan. 2015
thanks and how about if i want an 'or' or 'and' condition.
if x<3 "and" y>4 Running water; end
or
if x<3 "or" y>4 Running water; end
Geoff Hayes
Geoff Hayes am 21 Jan. 2015
The double ampersand is used for and, and the double pipe for or. For the and, you would do
if x<3 && y>4
Runningwater;
end
For the or, you would do
if x<3 || y>4
Runningwater;
end

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Dynamic System Models 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