IF cell of a dataset equal to text
Afficher commentaires plus anciens
Hi again.
I have a dataset with 100 rows of data with 4 columns.
I am trying to code the following and would like some help please:
For each row
If Table1.column1 = 'FOREX' (which is a string) and Table1.column4 < 0
then return Table1.column3 in Table1.column2
otherwise
If Table1.column1 = 'FOREX' (which is a string) and Table1.column4 >=0
then return Table1.column2 = (1% of Table1.column3) + Table1.column4
End
Réponse acceptée
Plus de réponses (1)
Matthew
le 16 Avr 2014
0 votes
6 commentaires
dpb
le 16 Avr 2014
ly isn't a table, it's a logical array (vector). Need to keep class types straight or you run into the problems below.
What are the types of ...nr and ...nr_Sec, respectively? You can't mix and match types or, as you've discovered, Matlab either chokes or sometimes will try to do an implicit cast for you...
Matthew
le 16 Avr 2014
Probably your problem is that they're character strings, maybe? I can't see your data itself but what does
CtpyList.customer_nr(iy,:) = CtpyList.Customer_nr_Sec(iy,:);
do? Does that solve the problem?
If not, post back with the results of
whos CtpyList.customer_nr(iy)
whos CtpyList.Customer_nr_Sec(iy)
for some location in iy -- say the first T would be ok.
Matthew
le 16 Avr 2014
dpb
le 16 Avr 2014
Good; thought it might.
You do understand why, then???
Matthew
le 17 Avr 2014
Catégories
En savoir plus sur Text Data Preparation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!