The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: string comparison comparison
Replies: 3   Last Post: May 21, 1998 11:47 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
H.J. Wang

Posts: 12
Registered: 12/7/04
string comparison comparison
Posted: May 21, 1998 10:42 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


I have two string variables, say,

var1 = 'sale';
var2 = 'none';

When asking whether var1 is NOT equal to var2, I want matlab to confirm
the answer that var1 is indeed not equal to var2. In other words, I
want the variable "ans" to be 1 instead of 0 from the following lines:

if var1 ~= var2,
ans = 1;
ans = 0;

However, Matlab returns ans = 0. I think it is because:

» var1 == var2
ans =
0 0 0 1

So that the assertation that var1 ~= var2 is not entirely true.
Nevertheless, is there anyway to let Matlab understand that I want to
compare the entire word rather than the letters? Thanks in advance.

H.J. Wang

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.