Prev: Rotation matrix used for what in body sensor in simmechanics
Next: Getting an houlry average from a data set
From: Ian Page on 21 Jun 2010 23:12 Is there a way to use conditional statements on text in Matlab? I'd like to set up something like: if TXT{i,1} = 'text' NUMERIC(i,1) = 1 end Nothing I've found online has helped so far.
From: Christopher on 22 Jun 2010 01:29
"Ian Page" <Ian1884(a)hotmail.com> wrote in message <hvp9m7$ije$1(a)fred.mathworks.com>... > Is there a way to use conditional statements on text in Matlab? I'd like to set up something like: > > if TXT{i,1} = 'text' > NUMERIC(i,1) = 1 > end > > Nothing I've found online has helped so far. You will most likely have to use 'strcmp'. Text can not be evaluated with an equality operator. In any case you should be using '==' instead of '=' to compare. Try: if strcmp(TXT{i,1},'text') NUMERIC(i,1) = 1; end |