Beta Tracks
Beta Tracks

Reputation: 273

Scilab - How to compare between numbers

Assume

s1 = 'Yes';
s2 = 'No';
tf = strcmp(s1,s2)

If not equal, it will provide 0 else 1.

The following above example is to compare between strings. But I can't do the same with numbers.

Upvotes: 0

Views: 248

Answers (1)

chthonicdaemon
chthonicdaemon

Reputation: 19760

You can simply use the comparison operators for numbers:

n1 = 1;
n2 = 2;
tf = n1 == n2

If you really want a 0 and a 1 for the false and the true, you can use

tf = bool2s(n1 == n2)

Upvotes: 1

Related Questions